I have a GWT project which will have several DataGrids. SO far I have implemented one (with an ASyncDataProvider
) and it's working just fine. But I really don't like all the messy, boiler-plate code to specify the columns. Here's a sample:
//some column
Column<DataRecord, String> dataColumn = new Column<DataRecord, String>(new TextCell()) {
public String getCellStyleNames(Context ctx, DataRecord record) {
//some columns have a style based on the value, calculate style here
}
public String getValue(DataRecord record) {
return record.getProperty();
}
};
dataGrid.addColumn(dataColumn);
dataGrid.setColumnWidth(dataColumn, 25, Unit.PX);
Is there a way to reduce the amount of code? Imagine a table with a dozen or so columns, the code gets very tedious. The grid itself is rendered by UiBinder but it seems UiBinder cannot go as far as specifying columns on a DataGrid.
I've had a look at this: Defining GWT CellTables with UiBinder but that involves using an HTML Table, but I don't want to lose all the functionality provided by DataGrid, so I'm reluctant to take that route.
Any other suggestions would be welcomed.