I have a JSON object like below which I need to display in Kendo Treeview with same hierarchy as the data itself. So far I am only able to display first level "RouteName" using dataTextField property.
{
"Data": [{
"RouteName": "My Route",
"Directions": [{
"Direction": "NorthBound",
"SomeProperty": "SomeValue",
"Braches": [{
"BranchName": "A",
"Routings": [4,5,6]
}]
}, {
"Direction": "SouthBound",
"SomeProperty": "SomeValue2",
"Braches": [{
"BranchName": "B",
"Routings": [0,1,2]
}]
}]
}]
}
Thanks to this answer I found an alternate which you can view here. However, I don't want to manually re-create the JSON object as specified in the answer. Is there a way Kendo can automatically pick up the hierarchy in JSON object and display it accordingly?
Unfortunately, there is no way, as far as I know, for the TreeView to use a regular json. It does makes sense though - how you want the data in the json to be displayed is something that an automatic process can't decide.
The only way to do it is to write your own recursive function that converts the regular json to a DataSource the Kendo TreeView can use. In this function you can decide for yourself how you convert the data in the json.
Let me know if you need some help with that.