Copy/Paste Layout using GOJS Libaray

Hello ,

We are using the Liecensed version for GOJS s/w.
Need an help on copying and Pasting the Layout/Digram in my code.
I tried the sample examples given on :
GoJS Commands -- Northwoods Software
Even tried to recall the the copy paste events using the handlers…SelectionCopied,ClipboardPasted…
But I am unable to copy the images/digrams ther.
Can anybody help us with the sample code for copy pasting Layout.

Thanks for all your help.Need your kind assistance asap.

I assume you are trying to copy nodes and links in code, not interactively – is that right? Can the user successfully select and copy and paste using the standard keys?

Did you want the user to select which parts to copy? If so, then you just need to call the CommandHandler methods copySelection and pasteSelection.

Or did you want to choose the parts programmatically? There are lots of ways of doing that. Add them to a List or a Set and then call Diagram.copyParts, all within a transaction.

Thanku so much for the update I am using the copySelection & pasteSelection commandhandler.
Can you please share good sample examples or any Link , so that idea to code using List or a Set will be more clear.

http://gojs.net/latest/intro/collections.html

Thanks for all your help.
1>But need one help on the point that the diagram i had copied are multiple for which need to hit DB and get the new generated ID’s for the Newly copied Diagram…Facing issue that how do I update the diagram so that particular generated ID will get bind …
2>Also can you tell me once I copy diagram how do I keep track on the selected item in the diagram and which diagram copied exactly in case having multiple diagrams…IS there any code for getting selected Item/Part copied and pasted.

  1. Yes, think of the keys in the Model as being temporary keys, which you can replace in the future by calling Model.setKeyForNodeData, Model | GoJS API.
    Remember also that you probably want to update only in a Model Changed listener when ChangedEvent.isTransactionFinished is true. Please read GoJS Changed Events -- Northwoods Software for more information about transactions.

  2. Those collections are available on the DiagramEvent. See the documentation for more details: DiagramEvent | GoJS API.

A post was split to a new topic: Copying, updating keys, layout