1
votes

I have two treepanels which I want to drag and drop between. I understand there is a plugin for this, however I want it to behave a certain way. In my treepanels, I am showing the root node of the tree, and then all its children. The default DD allows the user to drop items at different levels on the tree(i.e. sibling of root, child of root) where I want all items to be a child of root for consistency. How can I make it so that any drag into the treepanel associates the item as a child of the root and not a sibling of the root. Why: For a user who doesn't understand how this functionality works, one millimeter in either direction can change the item from being a sibling to child or vice versa.

Also, I would like it so I can only drag away those children and the root can't be moved, if at all possible.

1

1 Answers

1
votes

Yes it is possible. You can listen to the 'beforedrop' event on the target Tree panel's tree view and achieve what you want. Something like this http://jsfiddle.net/EYtnk/1/ .. One of the arguments of the beforedrop event is the node being dragged. You can check if it is a root node of source tree and just 'return false;'

P.S: In the example, i just used the same store for both the trees.. so the nodes get added on either side.