Save Group Node Placement on collapse?

Is it possible to have a group save it’s nodes’ positions on collapse? Here is my groupTemplate:

myDiagram.groupTemplate =
            Make(go.Group, "Auto",
            {
                layout: Make(go.GridLayout, { wrappingColumn: 1 }),
                selectable: true,
                isSubGraphExpanded: true,
            },
            Make(go.Shape, "Rectangle",  // surrounds the Vertical panel
                    {
                        fill: "rgba(128,128,128,0.33)",
                        fromSpot: go.Spot.Bottom,
                        toSpot: go.Spot.Top,
                        portId: ""
                    }
                ),
            Make(go.Panel, "Vertical",
                Make("SubGraphExpanderButton", { alignment: go.Spot.Left, margin: 5, width:30, height:30 }),
                Make(go.TextBlock,         // group title
                        { font: "Bold 12pt Sans-Serif", margin: 10 },
                        new go.Binding("text", "label")
                    ),
                Make(go.Placeholder,    // represents the area of all member parts,
                        { padding: 5 }       // with some extra padding around them
                    )
                )
            );

But if a user drags the nodes around that are in the group and collapses the group, when it is expanded the nodes all have their original position. Is there a way to configure this so the positions are retained?

Thanks!

That’s happening because the Group.layout is invoked again when the user expands the group. (Say you had added or removed some nodes or links while the group was collapsed.)

So it depends on what you want to do. I suppose you could just disable layout invalidation by setting isOngoing: false on the GridLayout that is your Group.layout. But there might be other times when you do want to cause an automatic layout, so it depends.

Read more about this issue at: GoJS Layouts -- Northwoods Software

 myDiagram.groupTemplate =
            Make(go.Group, "Auto",
            {
                layout: Make(go.GridLayout, { wrappingColumn: 1, isOngoing:false }),
                selectable: true,
                isSubGraphExpanded: true,
            },
            Make(go.Shape, "Rectangle",  // surrounds the Vertical panel
                    {
                        fill: "rgba(128,128,128,0.33)",
                        fromSpot: go.Spot.Bottom,
                        toSpot: go.Spot.Top,
                        portId: ""
                    }
                ),
            Make(go.Panel, "Vertical",
                Make("SubGraphExpanderButton", { alignment: go.Spot.Left, margin: 5, width:30, height:30 }),
                Make(go.TextBlock,         // group title
                        { font: "Bold 12pt Sans-Serif", margin: 10 },
                        new go.Binding("text", "label")
                    ),
                Make(go.Placeholder,    // represents the area of all member parts,
                        { padding: 5 }       // with some extra padding around them
                    )
                )
            );

Thanks setting the isOnGoing :false is looking good. I’ll have to play around with it somemore, but I’m pretty sure this is what we want.