0
votes

In Kendo TreeView I am trying to get an element of a node, To get node element I trying below code:

var dataItem = kendoTreeInstance.dataSource.get("2");
var dataElement = kendoTreeInstance.findByUid(dataItem.uid);

Since loadOnDemand is set to true, I am not getting the dataItem of child nodes. Is there any work around to get the dataItem of a child node when loadOnDemand is set to true.

2

2 Answers

1
votes

When using a TreeView, the underlying datasource is a HierarchicalDataSource, that handles instances of the Node type.

If loadOnDemand is true, you need to call the load() method of your dataItem (which is in fact a Node) before you can access its children.

Note that calling the load() method will trigger the change event of your datasource.

0
votes

In my scenario, I was able to solve this by expanding parent nodes in the kendo tree hierarchy till the child node using expandPath. Then I was able to get the data Item and data Element of the child node.