How to expand/collapse all panels in the diagram programatically?

Hi,
I want to expand/collapse all panels in the diagram,how can I do it programatically?

Could you provide a simplified template and examples of expanded and collapsed panels?

I assume you have seen the definition and uses of the “PanelExpanderButton”. http://gojs.net/latest/intro/buttons.html

Assuming your question is duplicated at How to stop the links to the empty space in scrolling table, I’ll also assume that you have just one “PanelExpanderButton” in your node template.

The Panel must have a name. Then it’s just a matter of:

myDiagram.startTransaction();
myDiagram.nodes.each (function(n) {
    var p = n.findObject("PANELNAME");
    if (p !== null) p.visible = false;
});
myDiagram.commitTransaction("collapsed all panels");