所以我想创建一个带有 kendo UI 树视图项的树,并将其绑定到作为 JSON 文件的远程分层数据源。
我希望生成的树类似于:
(汽车)
- (汽车)
----FM-1100
----FM-4200
--(自行车)
----FM-3100
(人员)
--(客户)
----GH-3000
--(贵宾)
----GH-3100
PS。() 中的名称应该类似于包含其“孩子”的文件夹
我已经在 kendo ui 网站上查看了有关上述所有内容的文档,但我对每次展开树中的项目时树视图用来加载更深阶段的整个回调函数有点困惑。
让我们以剑道文档中的示例为例:
var homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "http://demos.kendoui.com/service/Employees",
dataType: "json"
}
},
schema: {
model: {
id: "EmployeeId",
hasChildren: "HasEmployees"
}
}
});
$("#treeview").kendoTreeView({dataSource: homogeneous});
JSON 样本数据:
{
"employees": [
{"EmployeeId":2,"FullName":"Andrew Fuller","HasEmployees":true,"ReportsTo":null},
{"EmployeeId":3,"FullName":"Carl Jenkins","HasEmployees":true,"ReportsTo":null},
{"EmployeeId":4,"FullName":"Aston Miller","HasEmployees":false,"ReportsTo":2},
{"EmployeeId":5,"FullName":"Damon Sherbands","HasEmployees":false,"ReportsTo":2},
{"EmployeeId":6,"FullName":"Dariel Hanks","HasEmployees":true,"ReportsTo":null},
{"EmployeeId":7,"FullName":"Jason Jackson","HasEmployees":false,"ReportsTo":3},
{"EmployeeId":8,"FullName":"Reylen Scribbs","HasEmployees":false,"ReportsTo":6}
]
}
因此,我必须在“http://demos.kendoui.com/service/Employees”上设置一个休息服务器,该服务器接受来自提供“EmployeeId”的树的 GET,然后在文件中进行搜索并返回那些“ReportTo”收到“EmployeeId”...?? 树想要显示初始节点时会发生什么?
就像是:
@Path("/Employees")
@GET
@Produces(MediaType.TEXT_HTML)
public String returnEmployees(@QueryParam("EmployeeId") int accID) {
//search the employees.json
return "<head></head><body><pre>" + searchResultsString + "</pre></body>";
}
如何有效地搜索 JSON 文件并以字符串形式返回所有结果?或者,如果所有这些都是错误的,有人可以帮助我理解所有 GET 和回调的东西吗?也许它确实与我听说过的 jsonp 有关?这里有点迷失......
提前致谢