我试图使用此代码
How can i remove the expand arrow in kendo ui treeview if there are no child's to display
现在,它不是选定的答案,但它对我来说是部分工作
以下是我基于myChildren的答案
var inline = new kendo.data.HierarchicalDataSource({
data: @Html.Raw(dataSource),
schema: {
model: {
children: "Children",
hasChildren: function(e) {
var test = e.Children.length;
return test > 0;
}
}
}
});
我的代码如下所示:
children: "items",
//hasChildren: "Id" // Id I was using as that is a key
hasChildren: function(e) {
var test = e.items.length;
return test > 0;
}
问题,只要我点击展开任何父节点,我就会收到错误
Uncaught TypeError: Cannot read property 'length' of undefined
为什么会这样?
答案 0 :(得分:2)
听起来 items 属性有时为null。尝试先检查它是否存在。
return e.items && e.items.length;