Hi, I would like to grow the nodes in a group on the X axis to match the size of the parent.
I’m currently getting output like so:
But the desired output is as such:
I have created a codepen, but for some reason, on this pen, I cannot get the children to add themselves to the parent group. It should be self explanatory to an expert:
Here is the code:
var $$ = go.GraphObject.make;
// Diagram declaration
var myDiagram = $$(go.Diagram, "myDiagramDiv",
{
});
// Node template declaration
myDiagram.nodeTemplate = $$(go.Node, "Auto",
$$(go.Shape,
{
fill: "rgba(0,0,0,.1)",
strokeWidth: 0,
stretch: go.GraphObject.Horizontal,
cursor: "pointer",
},
new go.Binding("fill", "color")
),
$$(go.Panel, "Horizontal",
$$(go.TextBlock,
{
margin: 6,
font: "normal 11px sans-serif",
stroke: "white",
cursor: "pointer"
},
new go.Binding("text", "title")
),
$$(go.TextBlock,
{
margin: 6,
font: "normal 11px sans-serif",
stroke: "white",
cursor: "pointer"
},
new go.Binding("text")
)
)
)
myDiagram.groupTemplate = $$(go.Group, "Horizontal",
{ layout: $$(go.GridLayout, {
wrappingColumn: 1 ,
cellSize: new go.Size(1, 1),
spacing: new go.Size(0, 1)
}) },
$$(go.TextBlock,
{
margin: new go.Margin(8, 0, 4, 8),
alignment: go.Spot.TopCenter
},
new go.Binding("text", "title")
),
$$(go.TextBlock,
{
margin: new go.Margin(8, 0, 4, 8),
alignment: go.Spot.TopCenter
},
new go.Binding("text")
// .makeTwoWay()
),
$$(go.Shape,
{
strokeWidth: 0,
portId: "",
cursor: "pointer",
},
new go.Binding("fill", "color"),
),
$$(go.Panel, "Vertical",
$$(go.Placeholder,
{
margin: new go.Margin(0, 8, 8, 8),
alignment: go.Spot.Center,
padding: 20
}
)
)
)
// Model declaration
var nodeDataArray = [
{
isGroup: true, key: "1", color: "red", text: "Hey", title: "true"
},
{ group: "1", text: "very long string", title: "hh"},
{ key: "8", group: "1", text: "hello", title: "h"},
];
myDiagram.model = new go.TreeModel(nodeDataArray);
Thank you.