我有一段时间以来一直困扰着我的情况。我在我的项目中设置了一个Kendo UI树形视图,如http://demos.telerik.com/kendo-ui/web/treeview/events.html所述。Kendo UI Treeview折叠所有项目,只展开当前节点
我需要实现的是当我在树状视图上展开一个节点时,不在此分支中的所有其他节点都应该折叠并且在此分支上展开。我试过使用下面的代码,但不幸的是它进入了一个无限循环。
<div id="example" class="k-content">
<div id="treeview" class="demo-section" style="width: 200px"></div>
<div class="demo-section">
<h3 class="title">Console log
</h3>
<div class="console"></div>
</div>
<script type="text/javascript">
$(document).ready(function() {
function onExpand(e) {
e.preventDefault();
kendoTreeView.collapse('.k-item');
kendoTreeView.expand(e.node);
}
$("#treeview").kendoTreeView({
dataSource: [
{ text: "Furniture", expanded: true, items: [
{ text: "Tables & Chairs" },
{ text: "Sofas" },
{ text: "Occasional Furniture" }
] },
{ text: "Decor", items: [
{ text: "Bed Linen" },
{ text: "Curtains & Blinds" },
{ text: "Carpets" }
] },
{ text: "Storage" }
],
expand:OnExpand
});
});
</script>
请帮忙。
谢谢
超级酷。辉煌。这工作。你刚刚度过了我的一天。谢谢@OnaBai。 –