-
11 Dec 2011 11:58 AM #1
Expand TreeNode till certain Depth
Expand TreeNode till certain Depth
Hi,
This is the code to expand the treenode to certain depth, i have written 2 functions, in which one function gets recursively called till it completes expansion of given node till its given depth or till its leaf node
Also look at this article -Code://This Function recurses through everynode till conditions are met //Currently Depth is hard-coded to 4 but can be given a variable value to change as per situation myfunction = function(Mynode){ if(Mynode.hasChildNodes() == false || Mynode.getDepth() >= 4){ return; }else if(Mynode.hasChildNodes()){ Mynode.expand(false); Mynode.eachChild(myfunction); } } //this Function expands given node till depth given //As of now the depth is given 4 but can be changed as per requirement expandNodeTillDepth = function(treePanelId ,nodeId){ var PNode = Ext.getCmp(treePanelId).getNodeById(nodeId); PNode.collapse(true); PNode.expand(false); PNode.eachChild( myfunction ); } //Example Use - //expandNodeTillDepth('myTree','ynode-18',4)
http://mishranam.blogspot.com/2011/1...-depth-in.html
-
16 Jan 2012 11:33 AM #2
Get All child nodes (till max possible deep level) under a node
Get All child nodes (till max possible deep level) under a node
also look at -Code:/** * Following Function recurses through all nodes under the given node, * and return an Array of AsyncTreeNode objects (containing itself) * (Note - If the given Object is not desired in returned array can be easily * removed, using splice/slice methods of JS Array methods) */ getDeepAllChildNodes = function(node){ var allNodes = new Array(); if(!Ext.value(node,false)){ return []; } if(!node.hasChildNodes()){ return node; }else{ allNodes.push(node); node.eachChild(function(Mynode){allNodes = allNodes.concat(getDeepAllChildNodes(Mynode));}); } return allNodes; } //How To Use - //Consider I have a AsyncTreeNode/TreeNode - and want to get All its child nodes Array then var allChildNodes = getDeepAllChildNodes(Node); //OR var allChildNodes = getDeepAllChildNodes(Ext.getCmp(treePanelId).getNodeById(nodeId)); //OR to get All nodes in a Tree var allChildNodes = getDeepAllChildNodes(Ext.getCmp(treePanelId).getRootNode());
http://mishranam.blogspot.com/2012/0...ng-at-all.htmlLast edited by pramodkhare; 16 Jan 2012 at 11:35 AM. Reason: formatting


Reply With Quote