1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    8
    Vote Rating
    0
    pramodkhare is on a distinguished road

      0  

    Post 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
    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)
    Also look at this article -
    http://mishranam.blogspot.com/2011/1...-depth-in.html

  2. #2
    Sencha User
    Join Date
    Dec 2010
    Posts
    8
    Vote Rating
    0
    pramodkhare is on a distinguished road

      0  

    Default Get All child nodes (till max possible deep level) under a node

    Get All child nodes (till max possible deep level) under a node


    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());
    also look at -
    http://mishranam.blogspot.com/2012/0...ng-at-all.html
    Last edited by pramodkhare; 16 Jan 2012 at 11:35 AM. Reason: formatting

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi