I have added location but still it is not showing the new group.
here is my code…
var _go = go.GraphObject.make;
myDiagram = _go(go.Diagram, "myDiagramDiv",
{
grid: _go(go.Panel, "Grid", {gridCellSize: new go.Size(10, 10)},
_go(go.Shape, "LineH", {stroke: "#EAEAEA"}),
_go(go.Shape, "LineV", {stroke: "#EAEAEA"})
),
allowReshape: false,
allowResize: false,
allowRotate: false,
hasHorizontalScrollbar: false,
hasVerticalScrollbar: false,
padding: 0,
layout: _go(go.ForceDirectedLayout, {defaultSpringLength: 10}),
initialAutoScale: go.Diagram.UniformToFill,
autoScale: go.Diagram.Uniform,
maxSelectionCount: 2,
});
And then after the init();
I change some properties
setTimeout(function () {
myDiagram.toolManager.mouseWheelBehavior = go.ToolManager.WheelZoom;
myDiagram.layout.isOngoing = false;
myDiagram.defaultCursor = "grab";
myDiagram.contentAlignment = go.Spot.Left;
myDiagram.autoScale = go.Diagram.None;
}, 2500);
And following is the code for my group Template
myDiagram.groupTemplate = _go(go.Group, "Auto",
{
background: "rgba(51, 122, 183, 0.1)",
ungroupable: true,
computesBoundsAfterDrag: true,
handlesDragDropForMembers: true,
layout: _go(go.GridLayout, {
wrappingColumn: 3,
alignment: go.GridLayout.Position,
cellSize: new go.Size(1, 1),
spacing: new go.Size(10, 30)
})
},
_go(go.Shape, "Rectangle", {
fill: null,
stroke: "#337AB7",
strokeWidth: 2
}),
_go(go.Panel, "Vertical", // title above Placeholder
_go(go.Panel, "Horizontal", {
stretch: go.GraphObject.Horizontal,
background: "#337AB7"
},
_go("Button", {
"_expandedFigure": img_colaspe,
"_collapsedFigure": img_expand,
"_expandedFigureSize": new go.Size(15, 15),
"_collapsedFigureSize": new go.Size(15, 15),
click: expandGroup, //to expand or collapse the groups on button click
padding: 5
},
go.GraphObject.make(go.Picture, {
maxSize: new go.Size(15, 15),
source: img_colaspe
},
new go.Binding("source", "isSubGraphExpanded", function (exp, shape) {
var button = shape.panel;
return exp ? button["_expandedFigure"] : button["_collapsedFigure"];
}).ofObject(),
new go.Binding("maxSize", "isSubGraphExpanded", function (exp, shape) {
var button = shape.panel;
return exp ? button["_expandedFigureSize"] : button["_collapsedFigureSize"];
}).ofObject()
)
), // end button
_go(go.TextBlock, {
name: "GROUPTEXT",
alignment: go.Spot.TopLeft,
margin: 7,
font: "Bold 14px Sans-Serif",
stroke: "white"
},
new go.Binding("text", "name"))
), // end Horizontal Panel
_go(go.Placeholder, {padding: 25, alignment: go.Spot.TopLeft})
), // end Vertical Panel
new go.Binding("collaspeAll", "", colaspeGroupOnload)
);
expandGroup();
is called on click to expand the collapsed group
colaspeGroupOnload();
is called to collapse a group by default
Create new group Button code (Now with loc
parameter)
$("#btn_create").click(function () {
var nodeObj = {key: "new", text: $("#inputName").val(), name: $("#inputName").val(), isGroup: true, loc: "0 0"};
myDiagram.startTransaction("newGroup");
myDiagram.model.addNodeData(nodeObj);
myDiagram.commitTransaction("newGroup");
setTimeout(function () {
$("#zoneModal").modal('hide');
$("#btn_save").removeClass("disabled");
}, 200);
});
Do i need to use myDiagram.groupTemplateMap.add(..)
?? I cant figure out the reason of new group not showing…