Hello again))
Previously I created a label with the following configuration:
const labelNode = $(
go.Node,
'Viewbox',
{
resizable: true,
resizeObjectName: 'labelPanel',
},
new go.Binding('location', 'position', go.Point.parse),
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
$(go.Panel, 'Vertical', new go.Binding('itemArray', 'properties'), {
itemTemplate: $(
go.Panel,
'Vertical',
{
name: 'labelPanel',
defaultStretch: go.GraphObject.Horizontal,
background: 'transparent',
padding: new go.Margin(2, 2, 10, 2),
cursor: 'grab',
alignment: go.Spot.Left,
},
$(go.TextBlock, new go.Binding('text', 'name', (t) => t.toUpperCase()), {
textAlign: 'left',
stroke: uiTheme.label,
font: '12px Roboto',
margin: new go.Margin(0, 0, 2, 0),
}),
$(go.TextBlock, new go.Binding('text', 'value'), {
textAlign: 'left',
stroke: uiTheme.label,
font: '12px Roboto',
}),
),
}),
);
It gave me the following label:
Now we have another iteration, where it’s planned that the label will be expandable:
I planned to wrap the existing vertical panel into one more vertical panel and add a kind of a ‘header’ - a horizontal panel with a group name and button for collapsing before that panel with an array:
const labelNode = $(
go.Node,
'Viewbox',
{
resizable: true,
resizeObjectName: 'labelPanel',
},
new go.Binding('location', 'position', go.Point.parse),
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
//extra wrapper
$(go.Panel,
'Vertical',
// header
$(go.Panel,
'Horizontal',
{
alignment: go.Spot.Left,
},
// group name
$(go.TextBlock,
{
name: 'GROUP_NAME',
text: 'Some group name',
alignment: go.Spot.Left,
stroke: uiTheme.label,
maxLines: 1,
},
// new go.Binding('text', 'serial')), will work with bindings later
),
//expander itself
$('PanelExpanderButton',
'labelPanel',
{
alignment: go.Spot.TopLeft,
alignmentFocus: go.Spot.TopLeft,
}),
),
//properties array
$(go.Panel,
'Vertical',
new go.Binding('itemArray', 'properties'),
new go.Binding("visible").makeTwoWay(),// added this
{
itemTemplate:
$(go.Panel,
'Vertical',
{
visible: true, // added this
name: 'labelPanel',
defaultStretch: go.GraphObject.Horizontal,
background: 'transparent',
padding: new go.Margin(2, 2, 10, 2),
cursor: 'grab',
alignment: go.Spot.Left,
},
$(go.TextBlock,
new go.Binding('text', 'name', (t) => t.toUpperCase()),
{
textAlign: 'left',
stroke: uiTheme.label,
font: '12px Roboto',
margin: new go.Margin(0, 0, 2, 0),
}),
$(go.TextBlock,
new go.Binding('text', 'value'),
{
textAlign: 'left',
stroke: uiTheme.label,
font: '12px Roboto',
}),
),
}),// array end
)
);
However, the button looks like a big black square and does nothing on clicking. Could you please advise me - is it possible to do it with nesting panels, or do I have to use a table, as in the example?