This post will help you to achieve following:
- Checking/Unchecking all the nodes of a tree.
- Checking/Unchecking all the childnodes of a node.
- Checking/Unchecking all the siblings of a node.(see comments..)
If you want to check/uncheck all the node of a tree or all the child node of a parent node then following is the way to acheive it:
//function to check/uncheck all the child node. function toggleCheck(node,isCheck) { if(node) { var args=[isCheck]; node.cascade(function(){ c=args[0]; this.ui.toggleCheck(c); this.attributes.checked=c; },null,args); } } //this will also affect the passed parentNode(node).
Now calling this function for checking/unchecking all the node of a tree:
<br /> var tree=//ext js tree.<br /> toggleCheck(tree.root,true);//for checking all the nodes<br /> //or<br /> toggleCheck(tree.root,false);//for unchecking all the nodes<br />
Now calling above function for checking/unchecking all the children of a node:
<br /> var parentNode=//a node from tree.<br /> toggleCheck(parentNode,true);//for checking all the child nodes<br /> //or<br /> toggleCheck(parentNode,false);//for unchecking all the child nodes<br />
If you find any error or face any difficulty please let me know by comments.