I am facing another issue, that when a user clicks on a node in kendo treeview, onnodeclick event gets triggered. In its event handler, how can we get the parent nodes of that node?
1 Answer, 1 is accepted
0
Yanmario
Telerik team
answered on 28 May 2021, 02:26 PM
Hi Deepali,
When the TreeView is bound to flat data, each data item has its parent id, and this id can retrieve the parent. The item itself is available in the nodeClick handler event data as e.item.dataItem:
On the other hand, when the TreeView is bound to heterogeneous data, the data items don't have a notion about their parents (only their children). In such scenarios you will need to implement some custom logic to retrieve the parent item based on its hierachical index. The clicked item index is available in the nodeClick event data as e.item.index, the parent index will be the clicked item's index without the last "_xx". Here is a custom JavaScript sample implementation of the described approach:
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.