-
13 Sep 2007 4:17 AM #1
[solved] programatically unchecking checked tree nodes
[solved] programatically unchecking checked tree nodes
Hi-
Ext 1.1.1
AsyncTreeNodes
I've pored through the documentation and searched the forums with no luck. I'm trying to loop through all of the checked nodes in my tree and uncheck them, but I can't find a function and setting the property doesn't change their appearance in the UI.
Here's why I've been trying:
Anyone get something like this to work?Code:function clearChecks() { var a_checked_nodes = page_tree.getChecked("id"); for (var i = 0; i < a_checked_nodes.length; i++) { page_tree.getNodeById(a_checked_nodes[i]).attributes.checked = false; } }
Thanks,
-David
-
13 Sep 2007 4:58 AM #2
The default TreeNodeUI needs documenting.Code:myTree.getRootNode().cascade(function(n) { var ui = n.getUI(); ui.toggleCheck(true); });
-
13 Sep 2007 5:48 AM #3
Perfect, thanks!
Here's a snippet free for anyone to use
other modifications you might want to use could be:Code:/** * Toggle check boxes on a tree * @param TreePanel o_tree * @param bool b_checkState true to check all, false to uncheck all */ function toggleChecks(o_tree, b_checkState) { o_tree.getRootNode().cascade(function(n) { var ui = n.getUI(); ui.toggleCheck(b_checkState); }); }
or evenCode:/** * Pseudocode not tested... * Toggle check boxes on a tree * @param TreePanel o_tree * @param string s_node_id Node id to run function on * @param bool b_checkState true to check all, false to uncheck all */ function toggleChecks(o_tree, i_node_id, b_checkState) { o_tree.getNodeById(i_node_id).cascade(function(n) { var ui = n.getUI(); ui.toggleCheck(b_checkState); }); }
Code://pseudocode function toggleChecks(o_node, s_dir, b_checkState) { if (s_dir == 'up') { o_node.bubble(function(n) { var ui = n.getUI(); ui.toggleCheck(b_checkState); }); } else { o_node.cascade(function(n) { var ui = n.getUI(); ui.toggleCheck(b_checkState); }); } }
-
13 Sep 2007 5:53 AM #4
I've added docs for TreeNodeUI to SVN, and they'll show up in the next release.
-
27 Sep 2007 9:06 AM #5
but when you call tree.getChecked() ,you still get the node which is checked last time,and seems not checked now.
ok,i see .you also need to change the node attribute.
-
18 Jul 2012 12:29 AM #6
Ext.getCmp('selconWPanel').getRootNode().cascade(function(n){
var ui = n.getUI();
ui.toggleCheck(false);
});
this does not work. IE says: "对象不支持此属性或方法".


Reply With Quote