我无法获得剑道树来显示我一生的任何数据!我有一个返回这个 JSON 结构的 WebApi:
"Id":3,
"ParentId":0,
"FieldName":"",
"Value":"",
"OperationId":7,
"Children":[{
"Id":4,
"ParentId":3,
"FieldName":"",
"Value":"",
"OperationId":8,
"Children":[{
"Id":5,
"ParentId":4,
"FieldName":"xyz",
"Value":"abcd",
"OperationId":5,
"Children":null,
"HasChildren":false
},
"Id":6,
"ParentId":4,
"FieldName":"asdf",
"Value":"somedata",
"OperationId":5,
"Children":null,
"HasChildren":false
}],
"HasChildren":true},{.....blah blah you get the picture
我的JS如下:
var Tree;
var Root;
$(document).ready(function () {
Root = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "@Url.Action("GetData", "MyController")",
dataType: "json",
type: "POST",
data: { 'someId': 1 }
}
},
schema: {
model: {
id: "Id",
hasChildren: "HasChildren"
}
}
});
Tree = $("#treeview").kendoTreeView({
dataSource: Root,
dataValueField: "Id",
dataTextField: "OperationId",
});
});
我在这里做错了什么?Fiddler 和 chrome 从带有 json 数据的 WebApi 调用中显示出良好的结果。当页面加载时,Kendo 树控件会显示 Loading 微调器,然后它会变为空白。我已经认真地花了几个小时在这上面。
谢谢!