Multiple selection on multiple pages in Datagrid

Hi everyone,

Currently, when I select multiple items on one page of the DataGrid and navigate to another page, the previously selected items are not maintained. I would like to explore solutions that allow for selecting items on one page, navigating to another page, and still retaining the selected items.
Page 1:
image
Page 2:
image

Has anyone faced a similar requirement in their Jmix projects? I would greatly appreciate it if you could share any best practices, suggestions, or code examples to achieve multiple selection on multiple pages in the DataGrid.

Thank you in advance for your valuable insights and assistance.

Best regards,

Matar

Hi,

The reason why the selection state of items selected on different pages are not preserved is that when you switch pages the data is reloaded from DB with new firstResult and maxResult values, i.e. pagination is not just a visual effect but it reduces the amount of data loaded from DB. If you need to restore selection when navigation through different pages, then you need to implement it by your own, for example by subscribing on DataGrid’s selection event to store selection and to CollectionChangeEvent to restore selection.

Regards,
Gleb