Loading all Child Items on Clicked Node ONLY

6 posts, 0 answers
  1. Rick Nguyen
    Rick Nguyen avatar
    21 posts
    Member since:
    May 2006

    Posted 30 Aug 2014 Link to this post

    Hy,

    I have implemented js code to expand all child items under the selected NODE item.   And This Works FINE.

    Is there a build in way in KEDO Treeview do this ? a better way...I mean.


    OnRClickTreeNode()
    {
    var node = getTreeView().findByUid(getRightClickedItem().uid);
    var treeView = getTreeView();
    expandNodeChildItemsRecursive(treeView, node);
    }

    function expandNodeChildItemsRecursive(treeView, node) {
    treeView.expand(node);
    var childNodes = $(".k-item", node);
    for (var i = 0; i < childNodes.length; i++) {
    expandNodeChildItemsRecursive(treeView, childNodes[i]);
    }
    }
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 02 Sep 2014 Link to this post

    Hello Rick,

    Assuming that all child nodes are already loaded,calling treeview.expand(node.find(".k-item").addBack()); should expand all child items (instead of the expandNodeChildItemsRecursive function).

    Regards,
    Alex Gyoshev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Rick Nguyen
    Rick Nguyen avatar
    21 posts
    Member since:
    May 2006

    Posted 04 Sep 2014 in reply to Alex Gyoshev Link to this post

    thank you
  5. Rick Nguyen
    Rick Nguyen avatar
    21 posts
    Member since:
    May 2006

    Posted 04 Sep 2014 in reply to Alex Gyoshev Link to this post

    Also If say we have lazy loading implemented.
    How would be achieve loading all child items of a clicked node.  Not just one level down all levels from the clicked Node.
  6. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 05 Sep 2014 Link to this post

    Hello Rick,

    In order to achieve this, you need to bind an event handler to the dataBound event and expand the loaded children in it. Here is a snippet that shows how to expand all children that way. To limit the expansion only to the selected node, filter out the node event argument of the dataBound event to be within the selected one. See this Dojo snippet for an example with a dummy server.

    Regards,
    Alex Gyoshev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Rick Nguyen
    Rick Nguyen avatar
    21 posts
    Member since:
    May 2006

    Posted 06 Sep 2014 in reply to Alex Gyoshev Link to this post

    As always excellent solution Mr Alex.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready