Need to reset table to page 1 with code

Hi everyone. I’ve done well so far to find my way for the past six months, but now I have a small stumbling block.

I am displaying a table using code, but if a user changes the page to see more results (page 2 for example), it stays on that page when a new filter is applied.

There are several filters (buttons) and when a new filter is applied I would like the table to return to the first item on page one. Make sense?

It can’t be that hard to do, and I don’t want to re-filter the table, just re-sort it.
Thanks for any help with this…

Thank you!
After a couple hours of playing with it, I feel close but I’m not sure how to get the results to display in the table. The console shows the first page has indeed loaded, but it doesn’t refresh the table. It remains on page 2. The sorting still works though.

I’ve tried a few ways to code it but this is where I’m at. What am I missing?

$w(“#dataset2”).loadPage(1)
.then((results) => {
$w(“#dataset2”).setSort( wixData.sort()
.ascending(“title”)
);
});

Rob,
I know this was way back in January, but I have been looking to resolve the same issue to reset the table back to page 1 after filtering and sorting etc.

Did you by any chance manage to come up with a solution ??

Chiming in to say I’ve got the same problem and no solution yet…
Did anyone solve this?

You may use a workaround.

Let’s assume you are on page 3 and then you apply a filter that will produce less rows then the rowsPerPage. In that case, you could clear the page counter by changing the type of the table to virtual.

if (data.items.length < 10) {
  $w("#myTable").pagination = {"type": "virtual", "rowsPerPage": 10};
} else
  // return back the pagination
  $w("#myTable").pagination = {"type": "pagination", "rowsPerPage": 10};

If you play with this, you could get the desired behaviour.

PS In Wix Editor, the page is resetting on Page 1, but in live it is not. (a bug it is).

Any solution for this issue? I also need… (venko gligorov answer doen’t work for me)

Hi,
any solution?
i also need to change the paging back to page 1 after filter changed

Thanks