DataGrid Page Number

How can I tell which page I’m on in a DataGrid?

3 Likes

Good question. I was hoping there was a “change” event that could be monitored, but I don’t see one.

1 Like

(bump)

I need a way to know which page I’m on, or at least know when the navigation buttons have been clicked so I can keep a count myself (less than ideal that, but better than nothing).

Even a way to force the grid to go to a specific page would be useful then I could make my own navigation buttons.

4 Likes

I’m also running into this need.

I am refreshing a repeating panel (inside a data grid), and once items are refreshed, I’m forced back to page 1 on the data grid.

David, have you figured a way to control the page that is being displayed?

I’d love to be able to do something like:

page_num=self.data_grid_1.get_current_page()
self.data_grid_1.set_current_page(5)

Not yet, though I’ve been rushed off my feet the last week or so.

I’m trying to put together a custom datagrid component to manage things like this. If I can just get half a day to myself …

I’m never sure how to take Anvil Central’s silence - it could mean they are close to releasing an update or it could mean they don’t want to tell us they’re not working on it just yet :slight_smile:

Haha no worries at all.

Very late to the game here but you can get the page number with self.data_grid.get_page() :slight_smile:

p.s. you may also enjoy:

self.data_grid.next_page()
self.data_grid.previous_page()
self.data_grid.jump_to_first_page()
self.data_grid.jump_to_last_page()

6 Likes

Any chance we can add self.data_grid.jump_to_page(page_number)?

I would like to show something like Showing page 1 of 5 on the footer, next to the page control buttons.
Is there a page_changed event that I can use?

3 Likes

Hurrah! At last :slight_smile:

I very strongly second that.

I just as strongly second that as well.

edit
The problem with the data grid is that the pagination controls are not much use. They don’t tell you which page you’re on, how many pages there are, nor give you a way to go to a specific page. So you have to do all of that yourself, and it’s very clunky, almost negating the point of the data grid. At least with a full api we can do it ourselves in a consistent manner.

3 Likes

You know, I haven’t seen on-page-change under Feature Requests. I’ll add it, and everyone who’s interested can “like” it.

It is possible to implement this in terms of:
self.data_grid.get_page()
self.data_grid.jump_to_first_page()
self.data_grid.jump_to_last_page()
self.data_grid.next_page()
self.data_grid.previous_page()

That is, if we assume that the last two really mean
self.data_grid.jump_to_next_page()
self.data_grid.jump_to_previous_page()

I’m amazed that this is missing – seems like a must-have feature for searching through non-trivial tables, surely this comes up a lot.
E.g. gmail searching (“page x of y”).
An “on-page-change” event is an ugly workaround, have to add a 2nd UI element and code to tie them together.

Any progress on addressing this?

1 Like

Welcome to Anvil, @a.brooks !

If the data grid is not working for you, I can highly recommend @stucork 's Tabulator control :

You can add it as a 3rd party dependency, see here :

4 Likes

Thanks! I’m doing an initial investigation of Anvil, I was about to give up on it – but tabulator looks like it may do most of what I was looking for, I’ll check it out.