1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default Moving AsyncTreeNode to a new parent

    Moving AsyncTreeNode to a new parent


    I have tree structure like below using AsyncTreeNode and a treeloader

    root
    +-item1
    +----item2
    +------item3

    Is it possible to replace item2 with a new node and then change item2 parent to the new node to have something like below without going through all the nodes or reloading the tree

    root
    +-item1
    +----newnode
    +------item2
    +--------item3

    I tried just swapping parent node but without success.

    Code:
    newnode = new Ext.tree.AsyncTreeNode(attributesofnewnode);
    var item2= item1.firstChild; //gets item2
    
    item1.appendChild(newnode);
    
    item2.parentNode = newnode;

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You are not allowed to change parentNode (it's defined as read-only).

    Just use appendChild again, e.g.
    Code:
    newnode.appendChild(item2);

  3. #3
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    You are not allowed to change parentNode (it's defined as read-only).

    Just use appendChild again, e.g.
    Code:
    newnode.appendChild(item2);
    Tried that but it only appends item2 to newnode. I wanted to have item2 + all childnodes appended to newnode. I guess i will have to go through the childnodes one by one and append them back.

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    item3 is a child of item2, so it should be moved together with item2! Are you saying that it doesn't?

    Or does item1 have more children that need to be moved to newnode? That you have to do yourself.

  5. #5
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    item3 is a child of item2 and its not being moved. Actually there could be item3 child of item2 and item4 child of item3 etc... They are AsyncTreeNodes. Could that make a difference?

  6. #6
    Sencha User
    Join Date
    Sep 2009
    Posts
    112
    Vote Rating
    0
    asagala is on a distinguished road

      0  

    Default


    Actually I should be more precise. Item3 is not being moved and it actually disapear totally from the tree right after I append item2 to the newnode

Similar Threads

  1. Replies: 1
    Last Post: 29 Jun 2009, 9:20 AM
  2. Moving Element to a different parent
    By ben_dog in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 9 Sep 2008, 4:57 AM
  3. Search Parent of parent
    By AlainJS in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 7 Apr 2008, 5:32 AM
  4. Replies: 2
    Last Post: 28 Nov 2007, 9:02 AM
  5. Moving a node from an iframe to parent - IE problem
    By dustismo in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 30 Aug 2007, 11:58 AM

Thread Participants: 1