I am trying to use expandAll() and collapseAll() for a grouping grid Ext 4.1
But its not working after overriding: getting errors expandAll() is not defined
Ext.override(Ext.grid.feature.Grouping, {
collapseAll: function() {
var self = this, view = self.view;
view.el.query(self.eventSelector).forEach(function (group) {
var group_body = Ext.fly(group.nextSibling, '_grouping');
self.collapse(group_body);
});
},
expandAll: function() {
var self = this, view = self.view;
view.el.query(self.eventSelector).forEach(function (group) {
var group_body = Ext.fly(group.nextSibling, '_grouping');
self.expand(group_body);
});
}
});
Here is my view file:
Ext.define('MCT.view.MyGrid',
{
extend:'Ext.grid.Panel',
initComponent:function(){
var me = this;
this.bbar = [{xtype:'button',text:'Expand All', handler:function(){
me.features[0].expandAll();
this.callParent(arguments);
}}];
},
features : [{
ftype : 'grouping',
groupHeaderTpl :'.......',
startCollapsed : true
}]
});
Thanks in advance for your help!!
This works for me in my app...
xtype: 'tool',
type: 'collapse-top',
hidden: true,
handler: function (event, target, owner, tool) {
var agPanel = owner.up(), //getting thePanel
view = agPanel.view,
gFeature = view.features[0]; //I júst have one feautre... so [0] works
gFeature.collapseAll();
}
In my case I have placed the collapse-top tool into the toolbar which triggers the groupes. The curios thing is, that it only works if you get from the panel the view and from the view the grouping feature.
I think in your case it should work when you do this
var view = me.view;
view.features[0].expandAll();