I have constructed an application containing nothing but the following in the onModuleLoad method:
final ListGridRecord[] records = new ListGridRecord[1];
records[0] = new ListGridRecord();
records[0].setAttribute("population", new Integer(298444215));
final ListGrid grid = new ListGrid();
grid.setData(records);
grid.setGroupByField("population");
final ListGridField field = new ListGridField("population");
field.setType(ListGridFieldType.INTEGER);
field.setGroupValueFunction(new GroupValueFunction() {
public Object getGroupValue(Object value, ListGridRecord record, ListGridField field, String fieldName, ListGrid grid) {
return 1;
}
});
field.setGroupTitleRenderer(new GroupTitleRenderer() {
public String getGroupTitle(Object groupValue, GroupNode groupNode, ListGridField field, String fieldName, ListGrid grid) {
return "population";
}
});
grid.setFields(field);
grid.draw();
Running the application results in an exception:
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
at com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
If I remove the
grid.setGroupByField("population")
command, the example runs without exceptions. What am I doing wrong? What I am trying to do is to group ListGridRecordsā¦
Thanks in advance