gpt4 book ai didi

javascript - 本地和远程数据源到 Kendo Treeview

转载 作者:行者123 更新时间:2023-12-03 22:52:11 24 4
gpt4 key购买 nike

我想填充 Kendo TreeView,其中 2 个节点是本地数据源,最后一个节点应该是远程数据源

这是我的代码:

$("#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 是本地数据源,Monto Carlo 是远程数据源,但我不希望该节点再次成为它下面的 Monto Carlo,它应该是来自数据库的直接远程数据源

enter image description here
所以帮我解决这个问题

提前致谢!!!

最佳答案

您可以将 read 属性更改为函数:

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);结果是合并的数据源(远程和本地)。

关于javascript - 本地和远程数据源到 Kendo Treeview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38978823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com