View Full Version : [CLOSED] GroupingStore sort does not seem to work well

17 Sep 2008, 7:01 AM

I think there is a bug in the GroupingStore sort method.
I want my grid to be sorted first on the "grouped by" column, but when those "grouped by" columns have the same sort index, the group by does not work anymore.

At the beginning, everything is fine (the store is not sorted)


But when I sort the store (click on the "Player" header column) :


Here is my code :

package test.client;
import java.util.ArrayList;
import java.util.List;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.store.*;
import com.extjs.gxt.ui.client.widget.grid.*;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
public class App implements EntryPoint
public void onModuleLoad()
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
configs.add(new ColumnConfig("name", "Player", 200));
configs.add(new ColumnConfig("ctry", "Country", 60));
configs.add(new ColumnConfig("id", "ID", 30));
ColumnModel cm = new ColumnModel(configs);
GroupingStore<MyModel> store = new GroupingStore<MyModel>();
store.add(new MyModel(1, "Nadal Rafael" , "ESP", 2));
store.add(new MyModel(2, "Federer Roger" , "SUI", 2));
store.add(new MyModel(1, "Djokovic Novak", "SRB", 2));
store.add(new MyModel(3, "Murray Andy" , "GBR", 1));
store.add(new MyModel(3, "David Ferrer" , "ESP", 1));
store.setStoreSorter(new StoreSorter<MyModel>(){
public int compare(Store<MyModel> in_store, MyModel m1, MyModel m2, String property){
if ("id".equals(property)){
// Sort grouped column
return m1.sortIndex - m2.sortIndex;
// Sort other columns
String v1 = m1.get(property);
String v2 = m2.get(property);
return v1.compareToIgnoreCase(v2);
GroupingView view = new GroupingView();
view.setGroupRenderer(new GridGroupRenderer(){
public String render(GroupColumnData data)
return "Group " + data.models.get(0).get("id");
Grid<MyModel> grid = new Grid<MyModel>(store, cm);
grid.setSize(300, 300);
public static class MyModel extends BaseModel {
int sortIndex;
public MyModel(int groupId, String name, String country, int groupSortIndex) {
set("id", groupId);
set("name", name);
set("ctry", country);
sortIndex = groupSortIndex;
My config :
Windows XP
Host mode / EclipseThanks,

18 Sep 2008, 11:15 AM
The issue is your sorter. Comment it out and try your code.