View Full Version : Group sorting in Grid w/ grouping

7 Jul 2009, 7:46 AM
Hi, I have a Grid with grouping and I need to sort the groups with another criteria different from the default (for example, if you are using a string field to group records, the default sort is the alphabetical order).

Lets put an example using the demo here http://gwt-ext.com/demo/#gridGrouping
Grouping here is done using the 'industry' field, so groups are sorted using the alphabetical order of the industry (first Automotive, then Computer, etc...). What I need to do is to sort these groups under some other criteria, for example the number of records inside each group. Using this strategy groups would be listed as Automotive (1 record), then Food (2 records), .... last Manufacturing (9 records).

Is there any way to achieve this? The sorting function depends on some info inside the groups.

10 Jul 2009, 12:23 PM
I am actually having the same problem. I would like to sort on a field other than the grouping field. It looks like it always sorts on the grouping field in ascending order. Haven't quite figured out how to stop this.

10 Jul 2009, 12:33 PM
Found this thread which seems to have the answer to the issue. http://extjs.com/forum/showthread.php?t=71495

3 Aug 2009, 4:25 AM
i am having a problem with this one, the grid sorting works fine on default sort but if i try to sort it with other fields (by clicking on the grid header), the grouping sometimes gets messed up, items that should be in the same group are being divided into 2 or more groups with the same name, please help

21 Nov 2011, 8:41 AM
A short example of code may help you :

GroupingStore<ModelData> store = (GroupingStore<ModelData>) grid.getStore();
store.setStoreSorter(new StoreSorter<ModelData>() {
public int compare(Store<ModelData> store, ModelData m1, ModelData m2, String property) {
return ModelDataUtils.COMPARATOR.compare(m1, m2);

ModelData : your data
grid : your grid
ModelDataUtils.COMPARATOR : your comparator

9 Jan 2013, 7:27 AM
It seems GroupingStore has been removed from 3x. So, how can we achieve sorting on columns other than the one it's grouped by?

Colin Alworth
9 Jan 2013, 3:56 PM
We removed that in 3.x in favor of supporting more than one comparison at a time. The 3.x Store classes allow multiple StoreSortInfo objects to be added - where you used to group by one property then sort by another, now you just sort by one, then the other.