Resetting the offset for new query results

I have a page using a paged query and the pagination generator. I’ve also included an input field to search the database. It all works well, except for one problem.

Suppose a set of search results are displayed and I click on the link to display page 5. This works as expected and the parameter ‘?offset=40’ is displayed in the address bar (using Query Manager). However if I then do another search, page 5 is still displayed, whereas I would want page 1 to be displayed. Also, if the new results contain only a few records, the results page will be blank which might be puzzling.

I’ve tried assigning various events to the input field, and using Key Down with ‘query1.remove(‘offset’)’ for example seems to work.

I’m not sure if this topic should go under ‘How to’, ‘How Not to’ or ‘Bugs’. Is there a simpler solution I’ve overlooked- eg a checkbox I’ve missed somewhere? It might be simpler if I ran the query only when a button was clicked.

Community Page
Last updated: