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();
}
}
}
}
}
Aggregations