Expand subnode via code

3 posts, 1 answers
  1. Ruud
    Ruud avatar
    51 posts
    Member since:
    Oct 2012

    Posted 04 Jul 2015 Link to this post

    Hi,

    I try to use this tree list; i need to expand a complete parent-multiple children in the tree. So:

    - child deep in the hierarchy is known to my code and can be found in the tree list

    - via code, the complete tree needs to be expanded to expand the child itself and all its parents

    The demos only seem to work programmatically expanding nodes which are already displayed, but in this case the child nodes can be hidden. Is there a way to do this? Thanks in advance!

    Best regards,

    Ruud

  2. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 08 Jul 2015 Link to this post

    Hello Ruud,

    You can find the child node by id via the DataSource get method. Then, loop through all its parents (getting them via the parentNode method) and set their expanded state to true (node.set("expanded", true)).

    For a working sample, see this Dojo snippet.

    Regards,
    Alex Gyoshev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Ruud
    Ruud avatar
    51 posts
    Member since:
    Oct 2012

    Posted 08 Jul 2015 in reply to Alex Gyoshev Link to this post

    Hi Alex,

    Thanks! So easy lol.. I guess i was a bit confused by the code used for doing the treelist.select(), where you have to put in a jQuery selector. I assumed the expand command also would need jQuery selectors; never thought of the treelist datasource object to accomplish this.  Rtfm it is:(..

    Regards,

    Ruud

Back to Top