You can declare a grouping object and then call it from your GridPanel:
// grouping var grouping = Ext.create('Ext.grid.feature.Grouping',{ startCollapsed: true, // sets the default init collapse/expand all }); var grid = new Ext.grid.GridPanel({ store: store, columns: [ expander, ...
Then add this code to your GridPanel body:
// collapse/expand all botton tbar: [{ text: 'collapse all', handler: function (btn) { grouping.collapseAll(); } },{ text: 'expand all', handler: function (btn) { grouping.expandAll(); } }],
It will add two buttons that expand / collapse all groups. If you want everything to expand / collapse by default, pay attention to the variable "startCollapsed" above.
source share