0
如何在點擊dyna樹節點時自動選擇所有兄弟節點?我嘗試了一些代碼,但它不起作用。Dynatree:選擇節點時自動選擇所有兄弟節點
如何在點擊dyna樹節點時自動選擇所有兄弟節點?我嘗試了一些代碼,但它不起作用。Dynatree:選擇節點時自動選擇所有兄弟節點
您需要獲取所選節點的父節點,然後獲取該父節點的子節點(因此爲選定節點的兄弟節點)。
試試這個代碼:
<script type="text/javascript">
$(function() {
$("#tree").dynatree({
onActivate: function(node) {
// Get the selected nodes parents children (the selected nodes siblings)
var siblings = node.getParent().getChildren();
// Loop through all the siblings and set selected to true
for(var i=0; i<siblings.length; i++)
{
siblings[i].select(true);
}
},
children: [
{title: "Folder", isFolder: true, key: "folder",
children: [ {title: "Sub-item 1"}, {title: "Sub-item 2"}, {title: "Sub-item 3"} ]
}
]
});
});
</script>
<div id="tree"></div>
對不起已故reply..But它肯定會爲別人誰遇到同樣的要求有幫助。
所有我們需要做的是以下配置屬性設置爲3 selectMode:3 //這是多票數
基於它會自動採取更改父節點的狀態的護理孩子節點的狀態,反之亦然。
謝謝, Chitra