jQWidgets Forums

jQuery UI Widgets Forums General Discussions Navigation Tree how to get the children items of an item

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  xpblack 9 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • how to get the children items of an item #76107

    xpblack
    Participant

    Hi,

    I get the item using method getItem(). I want loop all the children Items of this item.
    Is there a way to access the children of an item?
    Thanks

    how to get the children items of an item #76113

    Vladimir
    Participant

    Hello xpblack,

    If you are using the items[] array approach for creating the tree list, you can access and edit the elements directly through the dataAdapater and update them there and then reset the source for the tree.

    Alternatively you can loop through the element.subtreeElement.children

    var selectedItem = ('#jqxTree').jqxTree('getItem', myItem);
    if (selectedItem.subtreeElement){
        for (var i = 0; i< selectedItem.subtreeElement.children.length; i++) {
            var childElement = $('#jqxTree').jqxTree('getItem', selectedItem.subtreeElement.children[i]);
            // do stuff to childElement
        }
    }

    Note that this will only get the first level children. If you need it to be recursive you will need to make it recursive yourself.

    Best Regards,
    Vladimir

    jQWidgets Team
    http://www.jqwidgets.com

    how to get the children items of an item #76123

    xpblack
    Participant

    Hi Vladimir,

    Thank you very much for you solution. It works perfect. 🙂

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

You must be logged in to reply to this topic.