【问题标题】:Kendo UI treeview remove the expand arrow in kendo ui treeview if there are no child's to display - not working properly如果没有要显示的孩子,剑道 UI 树视图删除剑道 UI 树视图中的展开箭头 - 无法正常工作
【发布时间】:2016-03-25 05:45:09
【问题描述】:

我正在尝试使用此代码

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
    

为什么会这样?

【问题讨论】:

    标签: javascript kendo-ui treeview kendo-treeview


    【解决方案1】:

    听起来 items 属性有时为空。先试试看是否存在。

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

    【讨论】:

    • 我会试试的,谢谢。我似乎对剑道有很多问题,我确实看到 stackoverflow 上有几个人似乎很了解剑道,但是由于它是一个商业产品,最好将问题发布到 Telerik/Kendo 论坛吗?无论如何,我有一个问题,如果你有机会,你可以看看我的这个问题,谢谢stackoverflow.com/questions/36228952/…
    • 我在展开箭头时遇到了同样的问题,但您的回答有所帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    • 2013-09-27
    相关资源
    最近更新 更多