I am using the nightly build (3 days old) of SmartGWTEE.
I wanted to use the groupBy feature of the ListGrid to group items by their type. My records contain a typeId, but I want to show the typeName. The example below shows the issue and I attach a screenshot.
What I had hoped was that groupBy would use the displayField, but the group title ignores this. In the screenshot, I expected the group to be the typeName "Value" not "100".
I wanted to use the groupBy feature of the ListGrid to group items by their type. My records contain a typeId, but I want to show the typeName. The example below shows the issue and I attach a screenshot.
What I had hoped was that groupBy would use the displayField, but the group title ignores this. In the screenshot, I expected the group to be the typeName "Value" not "100".
Code:
DataSource ds = new DataSource();
ds.setID("ds");
DataSource ds2 = new DataSource();
ds2.setID("ds2");
{
DataSourceTextField keyField = new DataSourceTextField("key");
keyField.setPrimaryKey(true);
DataSourceTextField valueField = new DataSourceTextField("value");
ds2.addField(keyField);
ds2.addField(valueField);
ds2.setClientOnly(true);
Record testRecord = new ListGridRecord();
testRecord.setAttribute("key2", "100");
testRecord.setAttribute("value", "Value");
ds2.setTestData(new Record[] { testRecord });
}
{
DataSourceTextField keyField = new DataSourceTextField("key");
keyField.setPrimaryKey(true);
DataSourceTextField valueField = new DataSourceTextField("key2");
valueField.setForeignKey(ds.getID() + ".key2");
ds.addField(keyField);
ds.addField(valueField);
ds.setClientOnly(true);
Record testRecord = new ListGridRecord();
testRecord.setAttribute("key", "1");
testRecord.setAttribute("key2", "100");
ds.setTestData(new Record[] { testRecord });
}
ListGrid grid = new ListGrid();
grid.setDataSource(ds);
grid.setAutoFetchData(true);
ListGridField key2Field = new ListGridField("key2");
key2Field.setDisplayField("value");
key2Field.setOptionDataSource(ds2);
grid.setFields(new ListGridField("key"), key2Field);
grid.setGroupByField("key2");
setSize("100%", "100%");
addChild(grid);
Comment