gpt4 book ai didi

javascript - Kendo UI TreeView - 单击已选择的节点

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

我有一个 Kendo UI Treeview,问题是当用户点击一个已经选择的节点时,select 事件不会触发。除了使用 jquery 单击类元素​​触发事件之外,还有其他方法可以做到这一点吗?

谢谢!

最佳答案

请尝试使用以下代码片段。

方法一:

<div id="treeview-left"></div>
<script>
var inlineDefault = new kendo.data.HierarchicalDataSource({
data: [
{
text: "Furniture", items: [
{ text: "Tables & Chairs" },
{ text: "Sofas" },
{ text: "Occasional Furniture" }
]
},
{
text: "Decor", items: [
{ text: "Bed Linen" },
{ text: "Curtains & Blinds" },
{ text: "Carpets" }
]
}
]
});

$("#treeview-left").kendoTreeView({
select: onSelect,
dataSource: inlineDefault
});

function onSelect(e) {
test();
}
$(document).on('click', '.k-state-selected', function () {
$("#treeview-left").data("kendoTreeView").trigger("select");
});

function test() {
//Your logic comes here
}
</script>

方法二:
<div id="treeview-left"></div>
<script>
var inlineDefault = new kendo.data.HierarchicalDataSource({
data: [
{
text: "Furniture", items: [
{ text: "Tables & Chairs" },
{ text: "Sofas" },
{ text: "Occasional Furniture" }
]
},
{
text: "Decor", items: [
{ text: "Bed Linen" },
{ text: "Curtains & Blinds" },
{ text: "Carpets" }
]
}
]
});

$("#treeview-left").kendoTreeView({
select: onSelect,
dataSource: inlineDefault
});

function onSelect(e) {
test();
}
$(document).on('click', '.k-state-selected', function () {
test();
});

function test() {
//Your logic comes here
}
</script>

如果有任何问题,请告诉我。

关于javascript - Kendo UI TreeView - 单击已选择的节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34329355/

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