View Full Version : TreePanel Drag and Drop: moving items inside a tree

6 Jul 2010, 6:06 AM

I am using a tree panel for maintaining a hierarchical list of bookmarks on the server-side.
I should also support scenario for moving bookmarks inside the tree.
here's the thing: Whenever a user drags a bookmark onto a folder, my target's DNDListener.dragDrop() is invoked and by getting event.getTarget() and feeding it to tree.findNode and then getModel() - I am able to get the destination folder. it looks like this:

Element target = event.getTarget();
TreeNode targetNode = tree.findNode(target);
targetTray = (TrayModel)targetNode.getModel();

However, when a user drags a bookmark in between two existing bookmarks, either in the same folder or in another folder, I get a null targetNode. I tried using target.getParent() with any possible depth, I tried target.getNextSibling and target.getPrevSibling(), but I cannot get the folder node in this scenario.

looking at the inner html of the target, I see an  . it's parent is TR, its parent TBODY, etc.

Is it somehow possible to get the drag destination folder even when the dragged item is dropped inside that folder and not directly onto it? Alternatively, is it possible to disallow drags other than ones on folders?


14 Sep 2011, 12:19 AM

I have the same problem now, did you manage to find the solution?

14 Sep 2011, 6:34 AM
So, it seems that solution is to get the dragged node model and then on the dragDrop event call the TreeStore getNextSibling or getPreviousSibling methods and pass them this model. This will return the corresponding models for the next/previous node.
Then the they can be used to gather required data and so on.

Heh, I spent 2 days trying to this through the DNDEvent methods :(