How can I automatically select all sibling nodes when clicking on a node of dyna tree? I have tried some codes but it's not working.
0
votes
2 Answers
0
votes
You need to get the parent of the selected node, then the children of that parent (therefore the siblings of the selected node).
Try this code:
<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>
0
votes
Sorry for the late reply..But it would definitely be helpful for others who come across the same requirement.
All we need to do is to set the following configuration property to 3. selectMode:3 // this is for multi-hier
it would automatically take care of changing the state of the parent node based on the children nodes' state and vice versa.
Thanks, Chitra