Table with server side pagination: reset to first page while searching?

How can I reset the table to reach on the first page while search results are getting updated on the table?

e.g. As currently when the user was on page 6 and tried to search but based on search it might result in fewer pages maybe 1 or 2 at that time there seems no data on the result as a user on page 6.

I might want the user to lead to page 1 so they can see any results if available.


Hey @jignesh! You can use your table’s .selectPage property to reset the page when you run whatever query is backing your search. One way to do that would be to write a JS Code query that runs table1.selectPage(1) and trigger it to run immediately after your search query. Does that help?

1 Like

Thanks @justin
Seems like this property will help.

1 Like

Hey, I was having a problem when doing table.selectPage(1) on query success, because it was then in the loop - changing/setting page caused it to reload because of pagination server-side.

So I added "on change" events with table.selectPage(0) (I discovered its an index, not a page number) to all selects which trigger data query.

Its not a perfect solution to have onChange event in multiple places, so if its possible to reset pagination BEFORE the query is run and not doing it outside of table, let me know.

Hey @poziminski!

For some extra context here how exactly do you have your search functionality set up? And what kind of pagination are you using? Does this table also happen to be in a module?