Unable to move tree node(s) properly

Unable to move tree node(s) properly

I have a tree which I want to move the nodes from one folder to another manually. However, it seems to appear to moved successfully on the screen, but not updated in the store/tree. Although this can be done via DnD, but I want to give user an option to do it manually with a menu button. After selecting a node to move follow by the button click, a popup of the same tree will appear. The treestore is being passed into the secondary panel to display the same tree as the primary panel. User will then need to select the new location. Group will move upon confirmation.

When I tried to move Child 2 to Child 3, it works and reflects well on the screen. But after which, when I tried to move Child 3 (together with its new child and grandchildren) to Child 1, only Child 3 is there. Child 2 and its 2 children are gone. So my guess is the store did not get updated at all!

Next, even if you don't want to use the DnD feature, consider reading at least how it works - you'd notice an important difference between your code and it. Instead of calling store.remove(M) and store.add(M,M), it uses the store.getSubTree method to get the full structure, removes that structure with store.remove (as you do), then insert it again with store.addSubTree. These *SubTree methods are designed to allow describing the children, grandchildren, etc of the node in question.

The processFolder method you are invoking probably looks likes the ones we use in some examples. This helper method is really only there to help *build* the tree with sample data - after the tree structure has changed within the store, you can't simply continue to use that method. The point was to tell the store about the structure, not to be the authoritative source of the structure after the store was finished.

Not sure if it is because the nodes were added to the store with the add(p, c) during initiation, instead of addSubTree when it was created. So when the first addSubTree was called, the IndexOutOfBound happened..