Expand node at a specific level

2 posts, 0 answers
  1. Udi
    Udi avatar
    36 posts
    Member since:
    Sep 2010

    Posted 26 Oct 2010 Link to this post


    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.

  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 29 Oct 2010 Link to this post

    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!

    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
Back to Top