Pagination - scroll remains in the same position after changing page

Hello,

I have a problem with switching pages in the pagination component. The scroll remains on the same position when I go to another page from the pagination.
For example if I am on page 2 and I scroll to the middle of the table and then go to page 3 the scroll remains on the same position as in page 2. I want the scroll to be on the beginning on the page when I switch pages.
Is there any property that needs to be set ? Tried to find something in: Pagination, JmixPagination, JmixPage, JmixAbstractPagination and JmixItemsPerPageLayout but I couldn’t find anything or maybe I missed something in.
Is there a property where we can set to scroll to the top if we go to another page in the pagination?

Thanks,
Blagoj

Hello!

Table does not change scroll position if Pagination is used separately, i.e. not inside like SimplePagination:

<groupTable id="table"
            width="100%"
            dataContainer="someDc">
         ...
        <simplePagination/>
</groupTable>

In your case you should subscribe to Pagination AfterRefreshEvent and manually set scroll to start:

@Autowired
private GroupTable<Order> table;

@Subscribe("pagination")
public void onPaginationAfterRefresh(PaginationComponent.AfterRefreshEvent event) {
    table.withUnwrapped(JmixTable.class, table -> table.setCurrentPageFirstItemIndex(0));
}
1 Like

Thanks for the fast response. It works fine with this.