Move 2 nodes simultaneously

I need 2 nodes that are connected, that when moving ‘node 1’ the ‘node 2’ moves together.
Sin%20t%C3%ADtulo

If Node2 is a tree-child of Node1, and if you want moving Node1 to also move all of Node1’s tree-children, then you need only set DraggingTool.dragsTree to true.

See, for example, the Incremental Tree sample: https://gojs.net/latest/samples/incrementalTree.html. Note how moving a node works after you have expanded the tree somewhat.

Note also that that sample also sets CommandHandler.copiesTree and CommandHandler.deletesTree, so that copying and deleting delete subtrees, just as moving does. You don’t have to user either setting if you don’t want to.

But if you want to choose nodes to move that are not exactly the set of subtree nodes and links, you can override DraggingTool.computeEffectiveCollection and decide exactly what you want to move even though the Parts are not selected. Several samples do this – just search the sources for those samples that do.

1 Like