无法让Kendo UI TreeView正确读取JSON数据中的子项

时间:2013-11-30 00:35:12

标签: kendo-ui

http://jsfiddle.net/N8Svz/5/

我确信我必须做一些愚蠢的事;就我所知,这似乎是HeirarchicalDataSource的教科书用法。

var domtree = [{
    "id": "linear1",
    "element-class": "LinearLayout",
    "children": [{
        "id": "static1",
        "element-class": "Static"
    }, {
        "id": "static2",
        "element-class": "Static",
        "children": [{
            "id": "static3",
            "element-class": "Static"
        }]
    }, {
        "id": "4",
        "element-class": "Error"
    }]
}];

var inline = new kendo.data.HierarchicalDataSource({
    data: domtree,
    schema: {
        model: {
            id: "id",
            children: "children"
        }
    }
});

$("#navtree").kendoTreeView({
    dataSource: inline,
    dataTextField: "id"
});

非常感谢能够指出我做错了什么的人!

2 个答案:

答案 0 :(得分:1)

我只是将字段children更改为items

这是一个jsfiddle:http://jsfiddle.net/nn007/N8Svz/6/

答案 1 :(得分:0)

如果您添加这样的架构属性,它可能会起作用。您告诉分层数据源儿童的关键是什么。像这样:

schema:{model:{children:" children" }}