You are right, the question is that if it has Items
no matter the length
it assumes that has children.
The solution is either do not generate those empty Items
or define treeDS
as:
var treeDS = new kendo.data.HierarchicalDataSource({
data : json,
schema: {
model: {
children : "Items",
hasChildren: function (node) {
return (node.Items && node.Items.length > 0);
}
}
}
});
You can see that I have defined a hasChildren
function that verifies that node.Items
exists and its length
is actually greater than 0
.
You might see it running in JSFiddle here