Search in sources :

Example 1 with ColumnData

use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.

the class IndicatorGridPanel method createColumnModel.

private ColumnModel createColumnModel() {
    ColumnConfig icon = new ColumnConfig("icon", 28);
    icon.setRenderer(new GridCellRenderer<ModelData>() {

        @Override
        public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            if (model instanceof IndicatorDTO) {
                int id = ((IndicatorDTO) model).getId();
                if (linked.contains(id)) {
                    return IconImageBundle.ICONS.link().getHTML();
                }
            }
            return "";
        }
    });
    ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.name(), 150);
    name.setRenderer(new GridCellRenderer<ModelData>() {

        @Override
        public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            StringBuilder html = new StringBuilder();
            html.append("<div style=\"margin-left: ").append(indent(model)).append("px;");
            if (!(model instanceof IndicatorDTO)) {
                html.append(";font-weight: bold;");
            }
            html.append("\">");
            html.append(model.get("name"));
            html.append("</div>");
            return html.toString();
        }
    });
    return new ColumnModel(Arrays.asList(icon, name));
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) Point(com.extjs.gxt.ui.client.util.Point) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 2 with ColumnData

use of com.extjs.gxt.ui.client.widget.grid.ColumnData 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 3 with ColumnData

use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.

the class ColumnModelBuilder method addTreeNameColumn.

public ColumnModelBuilder addTreeNameColumn() {
    ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.location(), 200);
    name.setRenderer(new TreeGridCellRenderer<ModelData>() {

        @Override
        public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
            return super.render(model, propertyName(model), config, rowIndex, colIndex, store, grid);
        }

        private String propertyName(ModelData model) {
            if (model instanceof SiteDTO) {
                return "locationName";
            } else {
                return "name";
            }
        }
    });
    columns.add(name);
    return this;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) SiteDTO(org.activityinfo.shared.dto.SiteDTO)

Example 4 with ColumnData

use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.

the class ColumnModelBuilder method addActivityColumn.

public ColumnModelBuilder addActivityColumn(final UserDatabaseDTO database) {
    ColumnConfig config = new ColumnConfig("activityId", I18N.CONSTANTS.activity(), 100);
    config.setRenderer(new GridCellRenderer<SiteDTO>() {

        @Override
        public Object render(SiteDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SiteDTO> store, Grid<SiteDTO> grid) {
            ActivityDTO activity = database.getActivityById(model.getActivityId());
            return activity == null ? "" : activity.getName();
        }
    });
    columns.add(config);
    return this;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 5 with ColumnData

use of com.extjs.gxt.ui.client.widget.grid.ColumnData 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

ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)10 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)10 SiteDTO (org.activityinfo.shared.dto.SiteDTO)5 ModelData (com.extjs.gxt.ui.client.data.ModelData)4 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)4 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)3 ListStore (com.extjs.gxt.ui.client.store.ListStore)2 Grid (com.extjs.gxt.ui.client.widget.grid.Grid)2 Point (com.extjs.gxt.ui.client.util.Point)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 CellEditor (com.extjs.gxt.ui.client.widget.grid.CellEditor)1 CheckColumnConfig (com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig)1 GridCellRenderer (com.extjs.gxt.ui.client.widget.grid.GridCellRenderer)1 TreeGridCellRenderer (com.extjs.gxt.ui.client.widget.treegrid.TreeGridCellRenderer)1 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)1 ReportMetadataDTO (org.activityinfo.shared.dto.ReportMetadataDTO)1 ReportVisibilityDTO (org.activityinfo.shared.dto.ReportVisibilityDTO)1 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)1