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]);
}
}
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
0
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
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.
How would be achieve loading all child items of a clicked node. Not just one level down all levels from the clicked Node.
0
Hello Rick,
Alex Gyoshev
Telerik
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.