How to drag and drop in tree - copy and move modes?


I know this is possible, but how can you drag and drop in the tree when enableMercyDrag is switched on and dragAndDropBehavior is set to ‘complex’.

I want to be able to either copy a node or move a node (they could have children too). How can this be done programmatically?

Ideally I would allow the user to select from a context menu where they choose to ‘Copy’ and ‘Paste’ which would copy a node to their preferred location or if the user selected ‘Move’ it would perform a ‘cut and paste’ operation. I need both states.

Please advise/provide examples as I couldn’t find any.


There is a moveItem method - you can move items within a tree.
If you use enableMercyDrag ‘true’ you copy the item, if ‘false’ - you move it.

Hi Darya,

Thanks for your response.

Does this mean I would have to toggle the enableMercyDrag? I think it could be complicated to allow users to either copy and paste or move items.

I am thinking of adding a copy and paste option to the context menu and disabling enableMercyDrag so that when the user selects ‘copy’ I grab the tree item ID and store it (in a hidden field) and then when the click ‘Paste’ from the context menu the tree is copied as new nodes using the stored tree item ID from before. Does this sound correct? any examples of this approach?

I may just allow the dnd to be move only.

Yes, you can use context menu, but how exactly to use it - it depends on your requirement.