jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree How to get the list of selected items?

This topic contains 7 replies, has 3 voices, and was last updated by  Peter Stoev 12 years, 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • How to get the list of selected items? #2433

    kated
    Member

    Hi,

    I am newbie. I am implementing the tree control in my website.
    I need to know how to get the list of selected items?

    Thanks for help!
    Kate

    How to get the list of selected items? #2434

    Peter Stoev
    Keymaster

    Hi Kate,

    In order to get the selected item, you can use this code:

    var selectedItem = $('#jqxTree').jqxTree('selectedItem');

    The following code returns the selected item’s label:

    var label = selectedItem.label

    Hope this helps you.

    Best Wishes,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to get the list of selected items? #2436

    kated
    Member

    Hi Peter,

    How can I go through the tree elements and get the list of the checked elements ( the checkbox is checked)

    Thanks!

    How to get the list of selected items? #2443

    Peter Stoev
    Keymaster

    Hi Kate,

    To get the list of all checked items, you can use this code:

                // get all items.
    var items = $("#jqxTree").jqxTree('getItems');
    // save all checked items in checkedItems array.
    var checkedItems = new Array();
    $.each(items, function () {
    if (this.checked) {
    checkedItems[checkedItems.length] = this.label;
    }
    });

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to get the list of selected items? #2466

    kated
    Member

    Thanks Peter. May I have one more question, please? I need to show the the list of checked items with the lable HTML control when the checkbox is checked.
    Is there any event trigger when I click on the checkbox? Could you show me, please?
    More details:
    I did this one for the tree onclick even of the tree. Whenever, users click to select the item, the getSelectedItem will be triggered. This one works fine.

    I need to know how can I trigger an even when I check on the checkbox.
    I appreciate your help!

    Kate

    How to get the list of selected items? #2467

    Peter Stoev
    Keymaster

    Hi Kate,

    You can use the ‘checkchange’ event to trigger when the user checks/unchecks a tree item’s checkbox.

    For example:

    $("#jqxTree").bind("checkchange", function (event) {
    var args = event.args;
    // tree UI element.
    var element = args.element;
    // check state.
    var checkState = args.checked;
    // tree item.
    var item = $("#jqxTree").jqxTree('getItem', element);
    // tree label.
    var label = item.label;
    });

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to get the list of selected items? #15988

    ryan paul
    Participant

    is it possible to get the child node only?
    if the parent node is selected then the child node will all be selected, so is it possible to get only the child node and disregard the parent node

    How to get the list of selected items? #16007

    Peter Stoev
    Keymaster

    Hi ryan paul,

    “checkChange” will be raised for any change in the checked state of any tree item.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.