Search in sources :

Example 1 with GroupTable

use of com.haulmont.cuba.gui.components.GroupTable in project cuba by cuba-platform.

the class GroupTableLoader method loadColumns.

@Override
protected List<Table.Column> loadColumns(final Table component, Element columnsElement, CollectionDatasource ds) {
    List<Table.Column> columns = new ArrayList<>();
    Element groupElement = columnsElement.element("group");
    if (groupElement != null) {
        columns.addAll(super.loadColumns(component, groupElement, ds));
        final List<Object> groupProperties = new ArrayList<>(columns.size());
        for (Table.Column column : columns) {
            if (column.isCollapsed()) {
                String msg = String.format("Can't group by collapsed column: %s", column.getId());
                throw new GuiDevelopmentException(msg, context.getFullFrameId());
            }
            if (column.isGroupAllowed()) {
                groupProperties.add(column.getId());
            }
        }
        context.addPostInitTask((context1, window) -> ((GroupTable) component).groupBy(groupProperties.toArray()));
    }
    columns.addAll(super.loadColumns(component, columnsElement, ds));
    return columns;
}
Also used : GroupTable(com.haulmont.cuba.gui.components.GroupTable) Table(com.haulmont.cuba.gui.components.Table) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Aggregations

GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 GroupTable (com.haulmont.cuba.gui.components.GroupTable)1 Table (com.haulmont.cuba.gui.components.Table)1 ArrayList (java.util.ArrayList)1 Element (org.dom4j.Element)1