我想填充Kendo TreeView,其中2个节点是本地dataSource,最后一个节点应该是远程数据源
这是我的代码:
$("#AftermarketTreeView").kendoTreeView({
dataTextField: ["text", "text", "MC_ANALYSIS_NAME"],
dataSource: {
data: [
{
text: "Initiate",
items: [
{ text: "Parts Selection", haschildren: false },
{ text: "Assumptions", haschildren: false },
{ text: "Team", haschildren: false },
]
},
{
text: "Analyze",
items: [
{ text: "Part Attributes", haschildren: false },
{ text: "Aftermarket Evaluation", haschildren: false }
]
},
{
text: "Monto Carlo",
items: [
{ text: "Monto Carlo", haschildren: true }
]
}
],
schema: {
model: {
hasChildren: "items",
children: {
schema: {
data: "items",
model: {
hasChildren: "haschildren",
children: {
schema: {
// override the schema.data setting from the parent
data: function (response) {
return response;
}
},
transport: {
read: {
url: ResolveUrl("/CreateMaintainAnalysis/GetMontoCarloData/"),
dataType: "jsonp",
data:onDataSendAnalysisID,
}
},
}
}
}
}
}
}
}
});
使用上面的代码我得到如下结构 其中Initiate和Analyze是Local DataSource,而Monto Carlo是Remote DataSource,但我不希望该节点再次成为Monto Carlo,它应该是来自数据库的直接远程DataSource
提前致谢!!!
答案 0 :(得分:0)
您可以将读取属性更改为函数:
read: function(options) { /* here you can do the ajax call for the remote dataSource and then you can merge the local dataSource with the remote dataSource, you can create a new array to accomplish this. */ }
您可以在here中看到一个示例。 想法是使用options.success(result);结果是合并的dataSource(远程和本地)。