Programatically control state of PanelExpanderButton

I have a panel with panelexpanderbutton as shown below.

As shown in above screenshot I can remove the panel content by clicking on “-” button and add content to panel by clicking on “+” button. I am able to control the visibility of the button by data size. My issue is when when I remove the data using “-” button and if panel is empty then the panelexpanderbutton is not visible. At this time the button is in expanded state so when I add data using “+” button it is expanding the panel. But I want the panel to be collapsed when I add data to empty panel.

I want to know is there a way to programatically control the expand and collapse state of PanelExpanderButton. Below is the code

(go.Panel, "Vertical", { name: "PROPERTIES",visible:false,columnSpan: 2}, new go.Binding("itemArray", "properties"), { row: 1, margin: new go.Margin(12,2,4,4), stretch: go.GraphObject.Fill, defaultAlignment: go.Spot.Left, background: "lightyellow", itemTemplate: propertyTemplate } ), (“PanelExpanderButton”, “PROPERTIES”,
{ row: 1, column: 1, alignment: go.Spot.TopRight, visible: false },
new go.Binding(“visible”, “properties”, function(arr:any)
{
return arr.length > 0;
}
)
),

If you look at the definition of “PanelExpanderButton”, http://gojs.net/latest/extensions/Buttons.js, you will see that it binds the expanded or collapsed appearance on the GraphObject.visible property of the named panel.

So just do:

  node.findObject("PROPERTIES").visible = true;  // or false

I notice that you have a Binding on the “PanelExpanderButton” itself – that will be independent of the visibility of the panel named “PROPERTIES”.

Could you please provide little more details.

Where should I use this code node.findObject(“PROPERTIES”).visible = true; // or false

How can I find node?

node is a reference to the Node or Part holding your “PanelExpanderButton”.

That is the answer to this question:

Presumably you know which nodes you want to modify this way.

Thank you. I figured it out.