Move group from palette to diagram, change the nodes position or location in the draging

is there a way to move group from palette to diagram, in the dragging , i changed some nodes size , but the copy from palette will keep the relative position in the dragging , when i keep moving mouse , the nodes will overlap,
so is there a way to change the nodes’s relative position inside the group?

Normally that is the responsibility of the Group.layout and of the templates you are using for both the Group and for the member Nodes.

i have used the grid layout for both of palette diagram , the group template map is the same , but the nodes inside of the group have different size and location for palette diagram, like this example GoJS Palette -- Northwoods Software, when drag from palette to diagram, the nodes location will keep the relative position in the dragging when move mouse , after dragging , the group will adjust to the right layout that i set for diagram , so the problem is in the dragging , i have tried all of the layout , there is no problem after drop, when draging move mouse ,there is a problem

Is the user dragging a Group from the Palette to the target Diagram, and that Group in the Palette has some member Nodes? And when being dragged over the target Diagram the copied Group looks wrong because its member Nodes are using the target Diagram’s node template(s) but with the node locations from the Palette? Are the node templates in both the Palette and the Diagram different from each other, but they both have a Binding on Node.location?

If I have understood your situation correctly, would it fix your problem if the node data location property were not copied between the palette’s model and the target diagram’s model?

1 Like

correct, so how to prevent the node data location property were not copied between the palette’s model and the target diagram’s model, or can i fix it by override computeEffectiveCollection, i deepclone the coll ,then i want to make some change for the coll ,like change the position , but i tried to change the position or location property for the coll ,nothing helps

You could override the data-copying behavior of the Palette.model by supplying a Model.nodeDataCopyFunction.

Hmmm, I’m just trying this, and it doesn’t work because DraggingTool automatically assigns the same Node.location to the copied nodes as the original nodes. So the Binding on “location” doesn’t matter.

So it seems that the only solution is to force a layout of the Group when the temporary Group is created upon the external drag. If your Group.layout is a TreeLayout, for example:

    myDiagram.toolManager.draggingTool.doSimulatedDragOver = function() {;
      var parts = this.copiedParts;
      if (parts && !parts.laidout) {
        parts.laidout = true;  // add this flag, to perform layout only once, initially
        parts.each(function(kvp) {  // for each Group
          var g = kvp.key;
          if (g instanceof go.Group) {
            // call Layout.doLayout with a LayoutNetwork consisting of the temporary Nodes and Links;
            // needed because temporary Parts are not normally laid out
            var net = new go.TreeNetwork(g.layout);
            g.memberParts.each(function(p) {
              if (p instanceof go.Node) net.addNode(p);
              else if (p instanceof go.Link) net.addLink(p);
   = net;
            // update the DraggingTool.copiedParts Map
            g.memberParts.each(function(n) {
              if (n instanceof go.Node) {
                parts.get(n).point = n.location.copy();

thanks ,let me try