这是Kendo Datasource的有效JSON吗?

时间:2016-01-14 14:07:37

标签: kendo-ui telerik

我无法在ken​​do treedatasource中显示值。这是Kendo TreeDataSourc的有效JSON吗?

"[{\"fields\": {\"tgtWeight\": 0.0, \"hasChildnode\": true, \"parent\": null, \"currWeight\": 0.0, \"classificationNameNode\": null, \"SSM\": \"ssm4\", \"ext_model_id\": 4}, \"model\": \"equity.usersecurityselectionmodel\", \"pk\": 14}]"

这是剑道方面。

var dataSource = new kendo.data.TreeListDataSource({
        transport: {
            read: {
                url: "../getModelTargetWeights?id="+id,
                dataType: "json"
            }
        },
        schema: {
            model: {
                id: "pk",
                parentId: "parent",
                fields: {
                           fields: { field: "fields"},
                           tgtWeight: {field: "tgtWeight", type :"number"}
                }
                }
            }
    });

   $("#treeList").kendoTreeList({
        dataSource: dataSource,
        editable: true,
        height: 540

1 个答案:

答案 0 :(得分:2)

您的dataSource架构应如下所示:

dataSource: {
    schema: {
        model: {
            id: "pk",
            parentId: "parent",
            fields: {
                parent: { nullable: true}
            }
        }
    }
}

并且JSON数组的每个元素都应包含hasChildren成员

更新: JSON数组本身:

[{\"tgtWeight\": 0.0, \"hasChildren\": true, \"parent\": null, \"currWeight\": 0.0, \"classificationNameNode\": null, \"SSM\": \"ssm4\", \"ext_model_id\": 4, \"model\": \"equity.usersecurityselectionmodel\", \"pk\": 14}]

示例:http://dojo.telerik.com/uJoLo