PDA

View Full Version : TreeNodes checked when parent is checked



yo_haha
15 Oct 2012, 1:09 AM
Hi,

1. I'm using ExtJS 3.4 TreePanel. I'd like to know if there is a way (function or attribute or ... that I didn't find) to automatically check children nodes when their parent is checked and to uncheck parent when all of its children are unchecked?

2. To uncheck the check box of an initially checked=true node, is the node.checked attribute that should be set to false or something else? I tried with the uncheck attribute but it didn't work.

Regards.

sword-it
15 Oct 2012, 2:41 AM
Hi yo_haha,

Try the following code -



var node = treePanel.getNodeById('your-id');
node.eachChild(function(n) {
n.getUI().toggleCheck(true);
});

If you want this to work whole subtree of the current node, you'll have to do some recursion like-



treePanel.on('checkchange', function(node, checked) {
node.eachChild(function(n) {
n.getUI().toggleCheck(checked);
});
});

yo_haha
15 Oct 2012, 4:29 AM
Thanks :)