use of com.extjs.gxt.ui.client.widget.grid.Grid in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addMapColumn.
public ColumnModelBuilder addMapColumn() {
ColumnConfig mapColumn = new ColumnConfig("x", "", 25);
mapColumn.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore listStore, Grid grid) {
if (model instanceof SiteDTO) {
SiteDTO siteModel = (SiteDTO) model;
if (siteModel.hasCoords()) {
return "<div class='mapped'> </div>";
} else {
return "<div class='unmapped'> </div>";
}
}
return " ";
}
});
columns.add(mapColumn);
return this;
}
use of com.extjs.gxt.ui.client.widget.grid.Grid 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