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

hasChildren re-evaluation

1 Answer 126 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 26 Nov 2018, 10:00 PM

i'm initializing a treeview control which has the hasChildren property set on the model as a function and a remote based datasource.

is there any way to force a re-evaluation of the hasChildren function on a given node without re-reading from the remote server?

 

 

 

1 Answer, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 28 Nov 2018, 04:02 PM
Hi Greg,

You could get the dataItem and directly access its hasChildren property. So, you could find the TreeView dataItem via the getByUid method of the dataSource:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/getbyuid

The code would look something as follows:

var treeView = $("#treeview").data("kendoTreeView");
var dataItem = treeView.dataSource.getByUid("3f88bc92-72c4-4f6e-8635-0f0e2bdb0606")
 
console.log(dataItem.hasChildren)

However, for removing and adding nodes to use the append method of the treeview and the remove method of the TreeView. Even if you could set the hasChildren field to new value, the already rendered node will not be updated, and thus, unexpected behavior might occur. 

https://docs.telerik.com/kendo-ui/api/javascript/ui/treeview/methods/append

https://docs.telerik.com/kendo-ui/api/javascript/ui/treeview/methods/remove

If you need further assistance, you might share more details on the use case you are implementing and a sample project of the achieved.

Regards,
Joana
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeView
Asked by
Greg
Top achievements
Rank 1
Answers by
Joana
Telerik team
Share this question
or