jQuery UI Widgets Forums Navigation Tree How to get children items?

This topic contains 2 replies, has 3 voices, and was last updated by  74bit 9 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • How to get children items? #77643

    yuanru
    Participant

    Hi,

    Is there any methods to get children items of a particular item? I didn’t find it in the api references. In order to get the children items, I enumerate all the items and check the parentElement property. But if there are many items, most of the enumerations are useless.

    How to get children items? #77644

    ivailo
    Participant

    Hi yuanru,

    There is no built in method about this functionality.
    Like a workaround you can use getItems method to return all the items and then to extract your needed items.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

    How to get children items? #78047

    74bit
    Participant
    var getChildItemsTree = function(selectorTree, item) {
    			var result = [];
    			var allItems = $(selectorTree).jqxTree('getItems');
    			for (var i in allItems) {
    				if(allItems[i].parentId == item.id) {
    					result.push(allItems[i]);
    					result.push(getChildItemsTree(selectorTree, allItems[i]));
    				}
    			}
    			return result;
    		},
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.