Search in sources :

Example 1 with SortableDataProvider

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);
}
Also used : GridSortOrder(com.vaadin.data.provider.GridSortOrder) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) GridSortOrder(com.vaadin.data.provider.GridSortOrder) SortableDataProvider(com.haulmont.cuba.web.widgets.data.SortableDataProvider)

Aggregations

MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 SortableDataProvider (com.haulmont.cuba.web.widgets.data.SortableDataProvider)1 GridSortOrder (com.vaadin.data.provider.GridSortOrder)1