jQWidgets Forums
jQuery UI Widgets › Forums › Getting Started › JQTree Widget GetChildren, GetAllChildren Enhancement
Tagged: jquery tree control
This topic contains 5 replies, has 3 voices, and was last updated by Dmitry Istomin 11 years, 3 months ago.
-
Author
-
I am very new to this list so forgive me if I am repeating an already asked question or request, but it appears to me that the above Methods would be a great enhancement to the Tree Widget.
Cheers,
Andy
Hi Andy,
The “getItems” method returns all Items loaded into jqxTree. You may learn more about it from the jqxTree’s API docs.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com+1 to Andy. If I am correct, you have to go through all the list of items to select children for a particular element. It would be great to have an opportunity of doing this without any iterations.
Hi Dmitry,
You can select only one item at a time. “getItems” returns all items. There’s is also a method – selectItem which allows you to select a specific item without iterating anything.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi, Peter!
Sorry, I probably mislead you. By select I meant get – get objects of items dynamically at runtime. I will try to explain myself to be more clear.
Result of getItems does not have any hierarchy. To get all root items I need to go through each item and check whether a parentElement property is null.
To get children of a particular item that is retrieved by getItem I need to call getItem again using subtreeElement property and then read nextItem property of each subsequent item until it is null.
So in each case we have to iterate through each item in a result to get a list of item’s children. I think it would be much better if you have items property in each item object or have getChildren method.
Please correct me if I am wrong.
Thank you!
Sorry, I realized that I was wrong about subtreeElement. It is a container for item elements and not a first child as I thought before. Here is a code which gets children for a particular element:
$(parentElement.subtreeElement).children(‘li’).each(function (i, c) {
item = e.jqxTree(‘getItem’, c);
//Some code which uses item object
})But anyway, it would be great to have a function getChildren(parent) which returns sub-items as objects. And if you provide no parent (or provide null) then it returns you all root items (e.g. those which do not have a parent).
Thanks!
-
AuthorPosts
You must be logged in to reply to this topic.