The datasource for my treeview is defined as follows:
legends = new kendo.data.HierarchicalDataSource({
schema: {
model: { id : "id", hasChildren: true, children: "layers" }
}
});
and my treeview is initialized like this:
$("#treeview").kendoTreeView({
checkboxes : { checkChildren : true },
dataSource: legends });
This is supposed to be a dynamic data source allowing me to add and remove items during runtime. When I add and remove items from legends, I expect the treeview to add and remove nodes accordingly. So when I later create a model like this:
var category = {id : 0, text : "some text", expanded : true, spriteCssClass : "folder", layers : [] }
and add it to the datasource using the add method
legends.add(category);
I should expect to see a tree node automatically created. This works.
If I later grab the category created above from legends.data() and add a child layer like this:
category.layers.push({ id : 1, text : " child", someOtherData : {} });
I do not see the child appear on the treeview and my application starts behaving abnormally. Then it occurred to me that the layers collection was not an observable and tried creating my categories like this:
var category = {id : 0, text : "some text", expanded : true, spriteCssClass : "folder", layers : new kendo.data.ObservableArray([]) }
With this change, I still get no children displayed and applpication appears to hang on call to category.layers.push().
What am I missing?
legends = new kendo.data.HierarchicalDataSource({
schema: {
model: { id : "id", hasChildren: true, children: "layers" }
}
});
and my treeview is initialized like this:
$("#treeview").kendoTreeView({
checkboxes : { checkChildren : true },
dataSource: legends });
This is supposed to be a dynamic data source allowing me to add and remove items during runtime. When I add and remove items from legends, I expect the treeview to add and remove nodes accordingly. So when I later create a model like this:
var category = {id : 0, text : "some text", expanded : true, spriteCssClass : "folder", layers : [] }
and add it to the datasource using the add method
legends.add(category);
I should expect to see a tree node automatically created. This works.
If I later grab the category created above from legends.data() and add a child layer like this:
category.layers.push({ id : 1, text : " child", someOtherData : {} });
I do not see the child appear on the treeview and my application starts behaving abnormally. Then it occurred to me that the layers collection was not an observable and tried creating my categories like this:
var category = {id : 0, text : "some text", expanded : true, spriteCssClass : "folder", layers : new kendo.data.ObservableArray([]) }
With this change, I still get no children displayed and applpication appears to hang on call to category.layers.push().
What am I missing?