On-page-change event for data grids

This is a follow-up to DataGrid Page Number

Currently, there is no direct way to know when the user has clicked on a paging button.

Workaround: using a timer, poll self.data_grid.get_page() to see when it changes.

5 Likes

I would like to second this and ask if you know of any updates that have occurred since this original post.

I ended up having to create my own buttons for pagination and used

Then manually tracked page counts and other events on the changes of these buttons. I would love it if these were inherent to the data grid themselves.

Edit:
The other thing I meant to mention was that it feels like the window should move to the top when the next page is clicked. If you have a data grid with a lot of information, you need to scroll a lot to the bottom. Then you hit next, and you are at the bottom of the next page (which is a bit strange from a UI perspective).

1 Like

Checking the docs… Nothing new in https://anvil.works/docs/api/anvil#DataGrid_attributes .

Agree with your Edit. Anyone who has such issues needs a Custom Component wrapper, or at least supplemental methods (a Custom nav bar?), to allow enforcement of such issues.

Here’s another: if you have an N-page grid, and you need to refresh the underlying data regularly, say, every 30 seconds or so, you may end up refreshing in the middle of the user’s navigation. They’re paging forward to page 15, say, but before they get there, the timer ticks, and suddenly, the data is refreshed out from under them. And it’s refreshed out from under Form code, too. This can raise Python exceptions.

And even if it doesn’t, suddenly they’re back at page 1!

For this reason, I had planned to turn timed refresh off, in several of my grids. Let the user refresh manually, e.g., via button. That way, we’re guaranteed to do all the steps in the right order. But your approach – custom navigation buttons – might give me a way to address this.

1 Like