pagination with code for search results

hi i need help with adding pagination to my search results page with some code, right now i have everything working fine i just need an example code to add some pagination to search results. i have added the pagination before but when you would click the next page it would reset the search results in the repeater.

Have you read the following pages yet?$w.Pagination.html

Additional info for you
If you wanted to do it for a dynamic page then simply have a look at these pages here.

Or for a simple go back button for example.


yes i know how pagination works and everything i need help with it not resetting the search results in the repeater when you click next page: for example if i search then results come up on a different page in a repeater and there are 20 items to display with 10 each page i would click next page and it would reset what you searched and just pull up the next items in the data set and not the filtered results i want sorry if that doesnt make sense.

1 Like

here is a similar article i tried to go off this but i wasn’t having any success

thank you for replying btw appreciate it !!!

There is probably a simple answer as to why it is being reset when you go to another page, however as you say, it shouldn’t happen when you use a simple pagination bar as it should just go to the next page of the results and show you the next bunch of search results etc.

Exactly as it says for the pagination reference…
For example, suppose you have a repeater connected to a dataset and that dataset is set to have a page size of 5. When the page loads, the repeater shows the first 5 items from the dataset. If a user clicks on the next page button of a pagination bar connected to the same dataset as the repeater, the repeater then shows items 6-10 from the dataset.

I’ve used tables on a site to display search results and the pagination on the dataset settings works fine and I can scroll through the table pages with all the filtered results being displayed fine, so I can’t understand myself why it is resetting every time you go to another page in your repeater.

Cross fingers that hopefully somebody with more knowledge can come along and give you a working answer for you. :crossed_fingers:

I’ve just used a simple data query search for my table to get my results.

export function searchButton_onClick(event) {
    .contains('songName', $w('#songnameinput').value)
    .then(res => {
      $w('#resultsTable').rows = res.items;

However, for your search in the repeater have you tried adding Wix Dataset - setFilter function?

Have a look at this simple example for a basic code example.

I’m just suffering with the same problem. I suppose the query is set back after changing pages due to the fact that the query is handled with code and not with the dataset. So if the dataset gets the instruction to load the next page it looks to me that it takes the unfiltered data from the collection instead of the code-filtered data and so the repeater gets populated unfiltered.
In my case I can’t use the dataset’s filtering because my setup uses 2 search bars which are not supported by the dataset.
Problem is I didn’t find a solution yet…

This post is an old post and is being closed.

Please add your own issue into a new post instead of bumping up an old post. Make sure you clearly explain your issue, what works, what doesn’t, and include your code.