Search in sources :

Example 6 with ColumnData

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

the class ColumnModelBuilder method addDatabaseColumn.

public ColumnModelBuilder addDatabaseColumn(final SchemaDTO schema) {
    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 = schema.getActivityById(model.getActivityId());
            return activity == null ? "" : activity.getDatabase().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 7 with ColumnData

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

the class ShareReportDialog method createColumnModel.

private ColumnModel createColumnModel() {
    ColumnConfig icon = new ColumnConfig("icon", "", 26);
    icon.setSortable(false);
    icon.setResizable(false);
    icon.setMenuDisabled(true);
    icon.setRenderer(new GridCellRenderer<ReportVisibilityDTO>() {

        @Override
        public Object render(ReportVisibilityDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ReportVisibilityDTO> store, Grid<ReportVisibilityDTO> grid) {
            return IconImageBundle.ICONS.group().getHTML();
        }
    });
    ColumnConfig name = new ColumnConfig("databaseName", I18N.CONSTANTS.group(), 150);
    name.setRenderer(new GridCellRenderer<ReportVisibilityDTO>() {

        @Override
        public Object render(ReportVisibilityDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ReportVisibilityDTO> store, Grid<ReportVisibilityDTO> grid) {
            return model.getDatabaseName() + " Users";
        }
    });
    visibleColumn = new CheckColumnConfig("visible", I18N.CONSTANTS.shared(), 75);
    visibleColumn.setDataIndex("visible");
    dashboardColumn = new CheckColumnConfig("defaultDashboard", I18N.CONSTANTS.defaultDashboard(), 75);
    dashboardColumn.setDataIndex("defaultDashboard");
    ColumnModel columnModel = new ColumnModel(Arrays.asList(icon, name, visibleColumn, dashboardColumn));
    return columnModel;
}
Also used : ReportVisibilityDTO(org.activityinfo.shared.dto.ReportVisibilityDTO) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) CheckColumnConfig(com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) CheckColumnConfig(com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig)

Example 8 with ColumnData

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

the class DatabaseGridPanel method createColumnModel.

private ColumnModel createColumnModel() {
    ColumnConfig icon = new ColumnConfig("icon", 28);
    icon.setSortable(false);
    icon.setMenuDisabled(true);
    icon.setRenderer(new GridCellRenderer<UserDatabaseDTO>() {

        @Override
        public Object render(UserDatabaseDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<UserDatabaseDTO> store, Grid<UserDatabaseDTO> grid) {
            return linked.contains(model.getId()) ? IconImageBundle.ICONS.link().getHTML() : "";
        }
    });
    ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.database(), 150);
    name.setSortable(false);
    name.setMenuDisabled(true);
    name.setRenderer(new GridCellRenderer<UserDatabaseDTO>() {

        @Override
        public Object render(UserDatabaseDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<UserDatabaseDTO> store, Grid<UserDatabaseDTO> grid) {
            if (hasPermission(model)) {
                return model.getName();
            } else {
                StringBuilder html = new StringBuilder();
                html.append("<span style=\"color: gray\">").append(model.getName()).append("</span>");
                return html.toString();
            }
        }
    });
    return new ColumnModel(Arrays.asList(icon, name));
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 9 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 SchemaDTO schema) {
    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 = schema.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 10 with ColumnData

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

the class ReportGridPanel method createColumnModel.

private ColumnModel createColumnModel() {
    ColumnConfig dashboard = new ColumnConfig("dashboard", "", 28);
    dashboard.setHeader(IconImageBundle.ICONS.star().getHTML());
    dashboard.setResizable(false);
    dashboard.setMenuDisabled(true);
    dashboard.setRenderer(new GridCellRenderer<ReportMetadataDTO>() {

        @Override
        public Object render(ReportMetadataDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ReportMetadataDTO> store, Grid<ReportMetadataDTO> grid) {
            return "<div style='cursor:pointer'>" + (model.isDashboard() ? IconImageBundle.ICONS.star().getHTML() : IconImageBundle.ICONS.starWhite().getHTML()) + "</div>";
        }
    });
    ColumnConfig title = new ColumnConfig("title", I18N.CONSTANTS.title(), 150);
    ColumnConfig owner = new ColumnConfig("ownerName", I18N.CONSTANTS.ownerName(), 100);
    owner.setRenderer(new GridCellRenderer<ReportMetadataDTO>() {

        @Override
        public Object render(ReportMetadataDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ReportMetadataDTO> store, Grid<ReportMetadataDTO> grid) {
            if (model.getAmOwner()) {
                return "Me";
            } else {
                return model.getOwnerName();
            }
        }
    });
    ColumnConfig email = new ColumnConfig("email", I18N.CONSTANTS.emailSubscription(), 100);
    email.setRenderer(new GridCellRenderer<ReportMetadataDTO>() {

        @Override
        public Object render(ReportMetadataDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ReportMetadataDTO> store, Grid<ReportMetadataDTO> grid) {
            switch(model.getEmailDelivery()) {
                case NONE:
                    return "<i>" + I18N.CONSTANTS.none() + "</i>";
                case MONTHLY:
                    return I18N.CONSTANTS.monthly();
                case WEEKLY:
                default:
                    return I18N.CONSTANTS.weekly();
            }
        }
    });
    return new ColumnModel(Arrays.asList(dashboard, title, owner, email));
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) ReportMetadataDTO(org.activityinfo.shared.dto.ReportMetadataDTO)

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