Search in sources :

Example 1 with Grid

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'>&nbsp;&nbsp;</div>";
                } else {
                    return "<div class='unmapped'>&nbsp;&nbsp;</div>";
                }
            }
            return " ";
        }
    });
    columns.add(mapColumn);
    return this;
}
Also used : ListStore(com.extjs.gxt.ui.client.store.ListStore) ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) Grid(com.extjs.gxt.ui.client.widget.grid.Grid) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) SiteDTO(org.activityinfo.shared.dto.SiteDTO)

Example 2 with Grid

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;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) CellEditor(com.extjs.gxt.ui.client.widget.grid.CellEditor) Grid(com.extjs.gxt.ui.client.widget.grid.Grid) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) ListStore(com.extjs.gxt.ui.client.store.ListStore) GridCellRenderer(com.extjs.gxt.ui.client.widget.grid.GridCellRenderer) TreeGridCellRenderer(com.extjs.gxt.ui.client.widget.treegrid.TreeGridCellRenderer)

Aggregations

ModelData (com.extjs.gxt.ui.client.data.ModelData)2 ListStore (com.extjs.gxt.ui.client.store.ListStore)2 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)2 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)2 Grid (com.extjs.gxt.ui.client.widget.grid.Grid)2 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 CellEditor (com.extjs.gxt.ui.client.widget.grid.CellEditor)1 GridCellRenderer (com.extjs.gxt.ui.client.widget.grid.GridCellRenderer)1 TreeGridCellRenderer (com.extjs.gxt.ui.client.widget.treegrid.TreeGridCellRenderer)1 SiteDTO (org.activityinfo.shared.dto.SiteDTO)1