Search in sources :

Example 11 with GridSortOrder

use of com.vaadin.data.provider.GridSortOrder 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)11 DataGridSettings (io.jmix.ui.settings.component.DataGridSettings)4 DataGrid (io.jmix.ui.component.DataGrid)3 Element (org.dom4j.Element)3 CubaEnhancedGrid (com.haulmont.cuba.web.widgets.CubaEnhancedGrid)2 Grid (com.vaadin.ui.Grid)2 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 SortableDataProvider (com.haulmont.cuba.web.widgets.data.SortableDataProvider)1 DataProvider (com.vaadin.data.provider.DataProvider)1 ListDataProvider (com.vaadin.data.provider.ListDataProvider)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 SortDirection (com.vaadin.shared.data.sort.SortDirection)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 DateRenderer (com.vaadin.ui.renderers.DateRenderer)1 HtmlRenderer (com.vaadin.ui.renderers.HtmlRenderer)1 ValoTheme (com.vaadin.ui.themes.ValoTheme)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 Captions (de.symeda.sormas.api.i18n.Captions)1 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)1