vaadin-component-factory / selection-grid-flow

Add the functionality to Vaadin Grid to focus on a particular row and column and select a range of rows with SHIFT/CTRL Click
https://incubator.app.fi/selection-grid-flow-demo/
Apache License 2.0
4 stars 8 forks source link

Highlighting does not work as expected if paging is enabled (by default) when more than pageSize rows are selected #35

Open kshashov opened 1 year ago

kshashov commented 1 year ago

Hi

We have been using the selection grid in our project since Vaadin 14. However, after updating to Vaadin 23, we found that it is no longer possible to accurately select more than DataCommunicator#pageSize rows.

@Route("/selection-grid-bug")
public class GridSelectionBugPage extends VerticalLayout {

    public GridSelectionBugPage() {
        List<Integer> items = IntStream.rangeClosed(1, 50).boxed()
                .collect(Collectors.toList());

        SelectionGrid<Integer> grid = new SelectionGrid<>();
        grid.setSelectionMode(Grid.SelectionMode.MULTI);
        grid.addColumn(s -> s);
        grid.setItems(items);

        // We reduce the page size to simplify the example
        grid.getDataCommunicator().setPageSize(10); // 50 by default

        grid.setSizeFull();
        add(grid);
        setSizeFull();
    }
}

selection-grid-paging-select

After a small research, we found out that the DataCommunicator#fetchFromProvider method has been updated and now it is necessary to turn off paging in order to get the old behavior.

This is not a problem for us, we just use the grid.getDataCommunicator().setPagingEnabled(false). But since other developers will also face this, we decided to share our experience here. Might need to update the readme or something like that.

circlesmiler commented 1 year ago

@kshashov Thank you very much. Your hint maybe saved my day. I've already replaced all grids and a first test (even by product management) looked promising. Maybe I have to redo all my changes, because we have some views with a lot of data. I hope this can be fixed easily. It's a blocker for us.

kshashov commented 1 year ago

@circlesmiler As far as I understand, the frontend component will continue to use internal pagination, it has a separate one. Only the data provider should be affected, for example, instead of two fetch invocations for 50 items, there will be only one fetch invocation for 100 items. If you are using the ListDataProvider provider, then there is nothing to worry about.