问题
I have a Kendo TreeView in which the parent nodes and children are all gotten at the same time.
Previously I was having the separate calls of which unless a Parent node was expanded, it did not call a query and pull that data into the parent node as children
Now that I have my data pulled all at once, I want to be able to do all sorts of CRUD operation in which if a node is created, deleted, sort order changed, then on Button click I want to send in all the data.
PROBLEM:
I noticed that in doing a console.log(mydatasource.data()); that I am seeing EMPTY children items.
Seems that if I expand ( or expand and collapse) THEN I get the children items to show up in chrome dev tools output
This is certainly a huge problem as I'm trying to send in the complete data and then run CRUD operations on all the data from essentially 3 database tables....
Why and how is this happening?
// show my data in chrome browser that is getting sent to mvc method
console.log(homogeneous.data());
Kendo TreeView
var homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot + "/GetReportGroupAssignments",
dataType: "json"
}
},
schema: {
model: {
id: "Id"
,
children: "items",
hasChildren: "Id"
}
}
});
var treeview = $("#treeview").kendoTreeView({
expanded: true,
dragAndDrop: true,
select: onSelect,
dataSource: homogeneous,
dataTextField: "ReportGroupName"
,
template: kendo.template($("#treeview-template").html()) //,
}).data("kendoTreeView");
回答1:
Try to set loadOnDemand to false.
来源:https://stackoverflow.com/questions/36228952/kendo-treeview-datasource-not-showing-children-items-in-javascript-debug-unless