Search in sources :

Example 1 with HeaderGroupConfig

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

the class PivotGridPanel method createColumnModel.

protected ColumnModel createColumnModel(PivotTableData data) {
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    ColumnConfig rowHeader = new ColumnConfig("header", "", 150);
    rowHeader.setRenderer(new RowHeaderRenderer());
    rowHeader.setSortable(false);
    rowHeader.setMenuDisabled(true);
    config.add(rowHeader);
    int colIndex = 1;
    List<PivotTableData.Axis> leaves = data.getRootColumn().getLeaves();
    for (PivotTableData.Axis axis : leaves) {
        String id = "col" + colIndex;
        String label = axis.getLabel();
        if (label == null) {
            label = I18N.CONSTANTS.value();
        }
        ColumnConfig column = new ColumnConfig(id, label, 75);
        column.setNumberFormat(IndicatorNumberFormat.INSTANCE);
        column.setAlignment(Style.HorizontalAlignment.RIGHT);
        column.setSortable(false);
        column.setMenuDisabled(true);
        propertyMap.put(axis, id);
        columnMap.put(colIndex, axis);
        config.add(column);
        colIndex++;
    }
    ColumnModel columnModel = new ColumnModel(config);
    int depth = data.getRootColumn().getDepth();
    int row = 0;
    for (int d = 1; d <= depth; ++d) {
        List<PivotTableData.Axis> children = data.getRootColumn().getDescendantsAtDepth(d);
        if (d < depth) {
            int col = 1;
            for (PivotTableData.Axis child : children) {
                int colSpan = child.getLeaves().size();
                columnModel.addHeaderGroup(row, col, new HeaderGroupConfig(child.getLabel(), 1, colSpan));
                col += colSpan;
            }
            row++;
        }
    }
    return columnModel;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) PivotTableData(org.activityinfo.shared.report.content.PivotTableData) ArrayList(java.util.ArrayList) HeaderGroupConfig(com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Aggregations

ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)1 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)1 HeaderGroupConfig (com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig)1 ArrayList (java.util.ArrayList)1 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)1