View Full Version : GroupingStore - How many groups exist based on the current grouping and sorting?

30 Jun 2010, 2:53 PM
I would like to either collapse or expand each group based on the number of groups and the number of rows in each group. I have found the methods to expand or collapse all groups, however, I can't seem to figure out how to determine how many groups exist or a way to iterate through the groups and ask each group for how many rows exist within that group. I am trying to do this inside of the 'load' listener - maybe there is a better place to put this code?

Any help or examples would be very much appreciated!


30 Jun 2010, 9:48 PM
That doesn't seem to be built in, however you could try these overrides:

Ext.override(Ext.data.GroupingStore, {
getGroupNames : function() {
return this.collect(this.groupField);
getNumberOfGroups : function() {
return this.getGroupNames().length;
getRecordsInGroup : function (group) {
return this.queryBy(function(r) {
return r.get(this.groupField) === group;
}, this);