Questions about the group

What’s the problem? If you are getting it to work with regular Nodes, it should work with Groups in the Palette.

Part Code:
// DF
var DFTemplate =
$(go.Group, go.Panel.Viewbox, // or “Viewbox”
{
resizable: true,resizeObjectName:“SHAPE”,
rotatable: true,
locationSpot: go.Spot.Center,locationObjectName: “SHAPE”},
{ selectionObjectName: “SHAPE” },
{background: null},
new go.Binding(“isShadowed”, “isSelected”).ofObject(),
$(go.Panel, “Spot”,//“Position”,
$(go.Shape, “Rectangle”,
{name:“SHAPE”,fill:“rgba(255,255,255,0)”,strokeWidth:2,stroke: “rgba(0,0,0,1)”,width:200, height:250}),
$(go.TextBlock,
{
editable: true, // editing the text automatically updates the model data
_isNodeLabel: true,
alignment: new go.Spot(1, 0.5,10,0),
cursor: “pointer”
},
new go.Binding(“font”, “font”),
new go.Binding(“stroke”, “color”),
new go.Binding(“text”, “text”).makeTwoWay()
)
)
);
myDiagram.nodeTemplateMap.add(“DF”, DFTemplate,{isGroup:true});
Result:

I wish I could create a group that is in the palette and can be dragged directly into the diagram.I did create a group, but it’s still a node.

For example,

But I want the rack to be dragged from the palette to the diagram,Instead of just drawing it right from the beginning.

Groups are Nodes, so dragging a Group from the palette should just work. As an example: Graphical Macros via Auto Ungrouping. Furthermore in that sample an “ExternalDroppedObjects” DiagramEvent listener ungroups that copied Group, but of course your app does not need to do that.

An unrelated issue, but it is odd to declare your Group to be a “ViewBox” Panel. That seems unnecessary.

Part Code
// DF
var DFTemplate =
(go.Group, go.Panel.Auto, { resizable: true,resizeObjectName:"SHAPE", rotatable: true, locationSpot: go.Spot.Center,locationObjectName: "SHAPE", selectionObjectName: "SHAPE", background: null, isSubGraphExpanded: false, ungroupable: true }, (go.Panel, “Spot”,
(go.Shape, "Rectangle", {name:"SHAPE",fill:"rgba(255,255,255,0)",strokeWidth:2,stroke: "rgba(0,0,0,1)",width:200, height:250}), (go.Placeholder, { padding: 10 }),
(go.TextBlock, { font: "bold 19px sans-serif", editable: true, _isNodeLabel: true, isMultiline:true, alignment: new go.Spot(1, 0.5,10,0), cursor: "pointer" }, new go.Binding("font", "font"), new go.Binding("stroke", "color"), new go.Binding("text", "text").makeTwoWay() ) ) ); // DF var pDFTemplate = (go.Group, go.Panel.Auto,
(go.Panel, "Position", (go.Shape, “Rectangle”,
{fill:“rgba(255,255,255,0)”,strokeWidth:2,stroke: “rgba(0,0,0,1)”,width:12, height:12,position: new go.Point(0, 0)})
)
);
myDiagram.groupTemplateMap.add(“DF”, DFTemplate);
myPalette.groupTemplateMap.add(“DF”, pDFTemplate);
myPalette.model.nodeDataArray = [
{key:1, category: “DF”,text:“DF”,font:“bold 8pt helvetica, bold arial, sans-serif”,color: “#000”,isGroup:true}];
Result:


Yes, DF is already a group,but how do I make this empty group have member nodes?I want the user to be free to drag the node into the DF group.Like this:

Take a look at how Groups are defined in the Regrouping sample, Regrouping Demo. Note the GraphObject.mouseDrop event handler which calls Group.addMembers or CommandHandler.addTopLevelParts for dragging nodes out of groups. Also, if you are using a Placeholder in your Groups, note setting Group.computesBoundsAfterDrag to true.

8 posts were split to a new topic: Rotating Groups