Search in sources :

Example 1 with SortableDataProvider

use of io.jmix.ui.widget.data.SortableDataProvider in project jmix by jmix-framework.

the class AbstractDataGrid 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(AbstractDataGrid.this, sortOrders, e.isUserOriginated());
    publish(SortEvent.class, event);
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) GridSortOrder(com.vaadin.data.provider.GridSortOrder) SortableDataProvider(io.jmix.ui.widget.data.SortableDataProvider)

Aggregations

GridSortOrder (com.vaadin.data.provider.GridSortOrder)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 SortableDataProvider (io.jmix.ui.widget.data.SortableDataProvider)1