[Data Grid Reactive] Automatic scroll to top of grid on pagination action
Forge component by OutSystems R&D
Application Type
Reactive

I'm trying to make the vertical scroll bar reset to the top whenever a pagination action happens. 

My DataGrid has 20 records per page and whenever I scroll all the way to the bottom and click on a new page, the vertical scroll bar stays at the bottom and the view of the grid is at the bottom. What I want to be able to do is reset the view of the grid such that I'm looking at the top of the DataGrid instead of the bottom.

With my current row height, whenever I go to page 2 from page 1, I'm looking at records 30-40 and if I want to look at records 21-29 I have to scroll up. I want to start at the top and see 21-29 and have to scroll down to 30-40.

So is there a way to control what happens after a pagination action is called or is there another way to go about getting the grid to automatically scroll to the top of the grid?

Solution

Hi Michael,

Sorry for the delay.

You can achieve this by adding a handler to the pageChanged event. I've attached an OML that on grid Initialization, adds this handler and scrolls to the top after changing page. Please notice, that this workaround might have unknown issues.

The highlighted part is responsible for scrolling to the top of the grid.

If you have any questions, feel free to ask.

Thank you,
Gabriel Lundgren

DataGridScrollOnPagination.oml

This worked perfectly. Thanks!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.