Go.js Copy Paste Tree not work

I am using go.js library for diagrams.
I want to implement the copy paste functionality. I have tried builtin functions for copy and paste.

var diag = window.canvas.getDiagramObject();
//for Copy
diag.commandHandler.copySelection();
//for Paste
var targetNode = window.canvas.getribbonTargetNode();
diag.commandHandler.pasteSelection(targetNode);

The problem with these methods are that they only copy selected node
from canvas. But i want to copy also childNodes of that selected node.

Anyone here for help?

First, do you know about the CommandHandler.copiesTree property? Setting this to true may be sufficient for your purposes.

  $(go.Diagram, ...,
    { ...,
      "commandHandler.copiesTree": true
    })

The CommandHandler.copiesParentKey might also be useful if you are working with a TreeModel and want the copied subtree to be added to the current parent.

Second, if you want to copy nodes and links programmatically, you can call Node.findTreeParts and Diagram.copyParts.

Third, there’s no point in posting in StackOverflow, this forum, and sending us email all at once.

Thank You This Was Beneficial And Helpful
[Smile] Thank You