Search in sources :

Example 1 with TableItems

use of io.jmix.ui.component.data.TableItems in project jmix by jmix-framework.

the class AbstractTableSettingsBinder method applyDataLoadingSettings.

@Override
public void applyDataLoadingSettings(Table table, SettingsWrapper wrapper) {
    EntityTableItems entityTableSource = (EntityTableItems) table.getItems();
    if (table.isSortable() && isApplyDataLoadingSettings(table) && entityTableSource != null) {
        TableSettings tableSettings = wrapper.getSettings();
        List<TableSettings.ColumnSettings> columns = tableSettings.getColumns();
        if (columns != null) {
            String sortProp = tableSettings.getSortProperty();
            if (sortProp != null) {
                List visibleColumns = Arrays.asList(getVTable(table).getVisibleColumns());
                MetaPropertyPath sortProperty = entityTableSource.getEntityMetaClass().getPropertyPath(sortProp);
                if (visibleColumns.contains(sortProperty)) {
                    if (table.getItems() instanceof TableItems.Sortable) {
                        ((TableItems.Sortable) table.getItems()).suppressSorting();
                    }
                    try {
                        com.vaadin.v7.ui.Table vTable = getVTable(table);
                        vTable.setSortContainerPropertyId(null);
                        vTable.setSortAscending(Boolean.TRUE.equals(tableSettings.getSortAscending()));
                        vTable.setSortContainerPropertyId(sortProperty);
                    } finally {
                        if (table.getItems() instanceof TableItems.Sortable) {
                            ((TableItems.Sortable) table.getItems()).enableSorting();
                        }
                    }
                }
            } else if (table.getSortInfo() != null) {
                TableItems tableItems = table.getItems();
                if (tableItems instanceof TableItems.Sortable) {
                    ((TableItems.Sortable) tableItems).resetSortOrder();
                }
            }
        }
    }
}
Also used : TableSettings(io.jmix.ui.settings.component.TableSettings) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) EntityTableItems(io.jmix.ui.component.data.meta.EntityTableItems) TableItems(io.jmix.ui.component.data.TableItems) EntityTableItems(io.jmix.ui.component.data.meta.EntityTableItems)

Aggregations

MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 TableItems (io.jmix.ui.component.data.TableItems)1 EntityTableItems (io.jmix.ui.component.data.meta.EntityTableItems)1 TableSettings (io.jmix.ui.settings.component.TableSettings)1