This is a migrated thread and some comments may be shown as answers.

Expand node at a specific level

1 Answer 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Udi
Top achievements
Rank 1
Udi asked on 26 Oct 2010, 12:20 PM
Hello,

How can i expand the treeview nodes at a specific level.

Let say i need to expand the treeview at level 2, so all the childs node at level 2 will expand.
Level 3 : all the childs of the childs will expand and so on.

I would like that the treeview will be render every time i set a new level.

Regards,
Oren

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 29 Oct 2010, 09:42 AM
Hello Oren,

Well, you can use the JavaScript Array as a Queue and implement Breadth-First traversal for a tree structure, and the current node should be checked for being on a certain level (on the client side this method is node.get_level()), if the answer is yes, then it should be added on the end of the queue, and you should not search it's children too.
When this algorithm has finished you can get the queue and in a single loop you can expand or perform any other needed action on the nodes that satisfied the search criteria (if expand you ca use node.set_expanded(true)).

I hope this helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Udi
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or