Copy/duplicate an existing tree

I have a treegrid which uses the dataprocessor to maintain persistence.



I need to be able to copy/duplicate a level zero node and all its children/grandchildren/etc into the same treegrid such that each of the new tree’s nodes have the appropriate unique node ids. Ideally the new level zero node’s copied label could be prepended with something like 'Copy of ', and that the focus would automatically switch/scroll to it once the copy/duplication was finished. Is there a suitable treegrid function that can do this?



Thanks and regards

You can copy branch of treegrid as

grid.moveRowTo(id,0,“copy”,“child”,grid,grid);

It will copy branch of grid, starting from row widh ID == id, on top level of the same tree.
You can use onDrop event ( basically it is programmatic d-n-d in copy mode ) to get ID of newly created item.

>>could be prepended with something like 'Copy of '
New items will have the same label but you can use setItemText to change it to necessary one.

Thank you very much.