I have a tree where I know the first level of nodes, and want to load dynamically children of those nodes.
How can I create a DataSource based on local data, and not have to define IDs manually? It seems that IDs are mandatory for loading further remote data.
I'm coming from Webix, where you can simply write:
With Kendo UI, if I don't define IDs, it seems there's no way to distinguish in the transport.read function between returning the first-level nodes from the local data, and loading child nodes of one of the first-level nodes:
How can I create a DataSource based on local data, and not have to define IDs manually? It seems that IDs are mandatory for loading further remote data.
I'm coming from Webix, where you can simply write:
webix.ui({
view:
'tree'
,
data: [
{ value:
'Programs'
,
}, {
value:
'Governance'
,
data: [
{value:
'Regulations'
},
{value:
'Policies'
},
{value:
'Standards'
}
]
}
],
on: {
onItemClick:
function
(nodeId, el) {
// nodeId is defined (automatically generated)
var
node =
this
.getItem(nodeId);
// will output the text of the clicked node
webix.message(node.value);
// load children of node.value via AJAX here...
}
}
});
With Kendo UI, if I don't define IDs, it seems there's no way to distinguish in the transport.read function between returning the first-level nodes from the local data, and loading child nodes of one of the first-level nodes:
var
myHDS =
new
kendo.data.HierarchicalDataSource({
transport: {
read:
function
(options) {
if
(!options.data.id) {
options.success([
{ ... hard-coded local data
for
the first level of nodes
... must hard-code IDs?
}
]);
return
;
}
// must have an id here
var
node = myHDS.get(options.data.id);
// load children from the sever via AJAX call