我无法在kendo 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
答案 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}]