Results 1 to 3 of 3

Thread: Help:how to append node to tree

  1. #1

    Default Help:how to append node to tree

    append new child node to end of tree , the parent of the new child can't not collapse and expand , the code like this:
    Code:
        ..........                  
                    var pid=Ext.getCmp('prdId').getValue();
    		var name=Ext.getCmp('prdlevelname').getValue();
    		var pnode = Ext.getCmp('prdTreePanel').getNodeById(pid);
    		// the child node can't show if the parent node collapse
    		pnode.expand(1,true,function(pnode){
    		          // add child node
    		         pnode.appendChild(new Ext.tree.TreeNode({id:id,text:name,leaf:true}));
                             //the parent node has not any child before append
    			pnode.attributes.leaf=false;
    			});
    ................

  2. #2
    Sencha User
    Join Date
    Feb 2008
    Location
    HCM, VietNam
    Posts
    23

    Default

    Try this:

    Code:
    var pid=Ext.getCmp('prdId').getValue(); 
    var name=Ext.getCmp('prdlevelname').getValue(); 
    var pnode = Ext.getCmp('prdTreePanel').getNodeById(pid); 
    if(pnode){ 
    	pnode.appendChild(new Ext.tree.TreeNode({id:id,text:name,leaf:true})); 
    	pnode.loaded = false; 
    	pnode.expand(false); 
    }
    Hope it works.

  3. #3

    Default

    same problem , the node not change when the child node append. the node has not been expand and collapse
    my work result like :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •