gpt4 book ai didi

javascript - 如果没有要显示的 child ,Kendo UI treeview 会删除 kendo ui treeview 中的展开箭头 - 无法正常工作

转载 作者:行者123 更新时间:2023-11-30 16:11:18 25 4
gpt4 key购买 nike

我正在尝试使用这段代码

How can i remove the expand arrow in kendo ui treeview if there are no child's to display

现在,它不是选定的答案,但它对我有部分作用

这是我的 hasChildren 基于的答案

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;
}
  1. 数据负载看起来不错。全部崩溃,我看到只有带子节点的父节点有箭头图标。完美
  2. 问题,只要我点击展开任何父节点,我就会得到一个错误

    Uncaught TypeError: Cannot read property 'length' of undefined

为什么会这样?

最佳答案

听起来 items 属性有时为 null。先尝试检查它是否存在。

return e.items && e.items.length;

关于javascript - 如果没有要显示的 child ,Kendo UI treeview 会删除 kendo ui treeview 中的展开箭头 - 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36214701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com