【问题标题】:Kendo UI HierarchicalDataSource schema not workingKendo UI HierarchicalDataSource 架构不起作用
【发布时间】:2013-12-11 12:59:41
【问题描述】:

我有一个剑道树,我正在尝试将它绑定到本地 json 数组。

试图将我的 json 对象属性映射到 treeView 预期的内容不起作用。

“文本”属性的值是函数定义 (function (item){ return item.Text; }) 函数本身不会被评估

jsfiddle

HTML:

<div id="tree"></div>

Javascript:

var data = [
    {
       "Text": "Some dummy text"
    }
];

var inlineDefault = new kendo.data.HierarchicalDataSource({
    data: data,
    schema: {
        model: {
            text: function(item){
                return item.Text;
            }
        }
    }
});

$("#tree").kendoTreeView({
    dataSource: inlineDefault
});

【问题讨论】:

    标签: javascript jquery kendo-ui kendo-treeview


    【解决方案1】:

    不要在数据源中使用投影,而是使用TreeView dataTextField 来定义数据的位置:

    var data = [
        {
           "Text": "Some dummy text"
        }
    ];
    
    var inlineDefault = new kendo.data.HierarchicalDataSource({
        data: data
    });
    
    $("#tree").kendoTreeView({
        dataTextField: "Text",
        dataSource: inlineDefault
    });
    

    【讨论】:

      【解决方案2】:

      不支持以这种方式定义架构模型 - 请参阅选项 here、分层数据源的附加字段 here 以及有关如何创建树视图的示例 here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-22
        • 1970-01-01
        • 2013-01-27
        • 2018-05-11
        相关资源
        最近更新 更多