I would like to know how can i check the sibling nodes of a tree while clicking on a particular node in ExtJs.
I had given id's for each node and i can access the id of a clicked node. then how can i proceed to checking the child nodes automatically ??
somebody please help me..
// or any other way of getting hands on the node you want to work with
var node = treePanel.getNodeById('your-id');
node.eachChild(function(n) {
n.getUI().toggleCheck(true);
});
If you want this to work on the whole subtree of the current node, you'll have to do some recursion.
A little more integrated:
treePanel.on('checkchange', function(node, checked) {
node.eachChild(function(n) {
n.getUI().toggleCheck(checked);
});
});
function nodeCheck(node) {
node.eachChild(function(n) {
if(n.hasChildNodes())
nodeCheck(n)
n.getUI().toggleCheck(false);
});
}
var node = (tree.getSelectionModel().getSelectedNode()) ? tree.getSelectionModel().getSelectedNode() : tree.root;
if(node) nodeCheck(node);
It works well for me ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With