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

Loading all Child Items on Clicked Node ONLY

5 Answers 105 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rick Nguyen
Top achievements
Rank 1
Rick Nguyen asked on 30 Aug 2014, 03:25 PM
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]);
}
}

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 02 Sep 2014, 08:57 AM
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.

 
0
Rick Nguyen
Top achievements
Rank 1
answered on 04 Sep 2014, 02:57 PM
thank you
0
Rick Nguyen
Top achievements
Rank 1
answered on 04 Sep 2014, 04:22 PM
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.
0
Alex Gyoshev
Telerik team
answered on 05 Sep 2014, 07:00 AM
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.

 
0
Rick Nguyen
Top achievements
Rank 1
answered on 06 Sep 2014, 02:19 PM
As always excellent solution Mr Alex.
Tags
TreeView
Asked by
Rick Nguyen
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Rick Nguyen
Top achievements
Rank 1
Share this question
or