use of com.extjs.gxt.ui.client.widget.grid.GridCellRenderer in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addIndicatorColumn.
public ColumnConfig addIndicatorColumn(IndicatorDTO indicator, String header) {
NumberField indicatorField = new NumberField();
indicatorField.getPropertyEditor().setFormat(IndicatorNumberFormat.INSTANCE);
ColumnConfig indicatorColumn = new ColumnConfig(indicator.getPropertyName(), SafeHtmlUtils.fromString(header).asString(), 50);
indicatorColumn.setNumberFormat(IndicatorNumberFormat.INSTANCE);
indicatorColumn.setEditor(new CellEditor(indicatorField));
indicatorColumn.setAlignment(Style.HorizontalAlignment.RIGHT);
// (it looks better if we don't)
if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SUM) {
indicatorColumn.setRenderer(new GridCellRenderer() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore listStore, Grid grid) {
Double value = model.get(property);
if (value != null && value != 0) {
return IndicatorNumberFormat.INSTANCE.format(value);
} else {
return "";
}
}
});
}
return indicatorColumn;
}
Aggregations