gpt4 book ai didi

jquery - Kendo Treeview 在子节点中获得无限循环

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

所以我的 Kendo Treeview 有问题。我得到了正确的父节点,但在子节点上,它具有与无限大的子节点相同的另一个级别。我试图在我的子节点中设置 'hasChildren = false ' 但它不起作用。希望你能帮我解决这个问题。

这是我的代码:

html:

<div id="treeview1"></div>

脚本:
  var Customer = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: '/Position/LoadGetCompanyList',
dataType: "json"
}
},
schema: {
model: {
id: "ID",
hasChildren: true,
children: Positions
}
}



});

var Positions = {
transport: {
read: {
url:'/Position/LoadIndustriesPositionList',
dataType: "json"
}
},
schema: {
model: {
id: "ID",
hasChildren: false

}
}

};
$("#treeview1").kendoTreeView({
dataTextField: ["CompanyName", "JobName"],
// dataValueField: "Client_CustomerID",
// select: function (e) {
// console.log("Selecting ", e.node)
// },
dataSource: Customer
}).data("kendoTreeView");

我在这里附上我的引用文献的链接:
http://rameshrajappan.wordpress.com/kendo-treeview-with-asp-net-mvc/
http://demos.telerik.com/kendo-ui/treeview/remote-data-binding

谢谢。

最佳答案

您需要以正确的顺序定义变量(先是 child ,然后是 parent )。 Positions 变量应该在 Customer 之前,因为 Customer 使用 Positions 作为其子代。

Kendo Treeview 的一个奇怪行为,如果顺序不正确, Kendo Treeview 会无限循环显示子节点。

更正后的代码应如下所示

var Positions = {
transport: {
read: {
url:'/Position/LoadIndustriesPositionList',
dataType: "json"
}
},
schema: {
model: {
id: "ID",
hasChildren: false

}
}

};

var Customer = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: '/Position/LoadGetCompanyList',
dataType: "json"
}
},
schema: {
model: {
id: "ID",
hasChildren: true,
children: Positions
}
}



});


$("#treeview1").kendoTreeView({
dataTextField: ["CompanyName", "JobName"],
// dataValueField: "Client_CustomerID",
// select: function (e) {
// console.log("Selecting ", e.node)
// },
dataSource: Customer
}).data("kendoTreeView");

关于jquery - Kendo Treeview 在子节点中获得无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25985983/

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