use of com.haulmont.cuba.web.widgets.data.SortableDataProvider in project cuba by cuba-platform.
the class WebAbstractDataGrid method onSort.
protected void onSort(com.vaadin.event.SortEvent<GridSortOrder<E>> e) {
if (component.getDataProvider() instanceof SortableDataProvider) {
// noinspection unchecked
SortableDataProvider<E> dataProvider = (SortableDataProvider<E>) component.getDataProvider();
List<GridSortOrder<E>> sortOrders = e.getSortOrder();
if (sortOrders.isEmpty()) {
dataProvider.resetSortOrder();
} else {
GridSortOrder<E> sortOrder = sortOrders.get(0);
Column<E> column = getColumnByGridColumn(sortOrder.getSorted());
if (column != null) {
MetaPropertyPath propertyPath = column.getPropertyPath();
boolean ascending = com.vaadin.shared.data.sort.SortDirection.ASCENDING.equals(sortOrder.getDirection());
dataProvider.sort(new Object[] { propertyPath }, new boolean[] { ascending });
}
}
}
List<SortOrder> sortOrders = convertToDataGridSortOrder(e.getSortOrder());
SortEvent event = new SortEvent(WebAbstractDataGrid.this, sortOrders, e.isUserOriginated());
publish(SortEvent.class, event);
}
Aggregations