This content has been marked as final.
Show 1 reply
-
1. Re: Expand Tree Nodes
domelq Dec 6, 2007 11:14 AM (in response to pankaj.ghosh)Hi i did it on client side just see the code bellow. I think also that somehow you could get state of a tree from stateVar attribute instead of hardCoded 'Richfaces_Tree_tree_tree'. The name of a tree on client side can be checked in DOM Window object
function collapseAll() { var tree = window['Richfaces_Tree_tree_tree']; var childs = tree.childs; collapse(childs); } function expandAll(){ var tree = window['Richfaces_Tree_tree_tree']; var childs = tree.childs; expand(childs); } function collapse(childs) { for (var i = 0; i < childs.length; i++) { var element = childs; var cc = element.childs; if (cc.length != 0) { if (!element.isCollapsed()){ collapse(cc); element.eventCollapsionClick(); } } } } function expand(childs) { for (var i = 0; i < childs.length; i++) { var element = childs; var cc = element.childs; if (cc.length != 0) { if (element.isCollapsed){ element.eventCollapsionClick(); expand(cc); } } } }
Hope this will help