This sample allows the user to drag nodes, including groups, into and out of groups, both from the Palette as well as from within the Diagram. See the Groups Intro page for an explanation of GoJS Groups.

Highlighting to show feedback about potential addition to a group during a drag is implemented using GraphObject.mouseDragEnter and GraphObject.mouseDragLeave event handlers. Because Group.computesBoundsAfterDrag is true, the Group's Placeholder's bounds are not computed until the drop happens, so the group does not continuously expand as the user drags a member of a group.

When a drop occurs on a Group or a regular Node, the GraphObject.mouseDrop event handler adds the selection (the dragged Nodes) to the Group as new members.

The TextBlocks use the GraphObject.opacity property, which allows for the text to somewhat match the color of what it's on top of.

The slider controls how many nested levels of Groups are expanded. Semantic zoom level:

Diagram Model saved in JSON format:
{ "class": "go.GraphLinksModel", "nodeDataArray": [ {"key":1, "text":"Main 1", "isGroup":true, "category":"OfGroups"}, {"key":2, "text":"Main 2", "isGroup":true, "category":"OfGroups"}, {"key":3, "text":"Group A", "isGroup":true, "category":"OfNodes", "group":1}, {"key":4, "text":"Group B", "isGroup":true, "category":"OfNodes", "group":1}, {"key":5, "text":"Group C", "isGroup":true, "category":"OfNodes", "group":2}, {"key":6, "text":"Group D", "isGroup":true, "category":"OfNodes", "group":2}, {"key":7, "text":"Group E", "isGroup":true, "category":"OfNodes", "group":6}, {"text":"first A", "group":3, "key":-7}, {"text":"second A", "group":3, "key":-8}, {"text":"first B", "group":4, "key":-9}, {"text":"second B", "group":4, "key":-10}, {"text":"third B", "group":4, "key":-11}, {"text":"first C", "group":5, "key":-12}, {"text":"second C", "group":5, "key":-13}, {"text":"first D", "group":6, "key":-14}, {"text":"first E", "group":7, "key":-15} ], "linkDataArray": [ ]}