Going through a table - combination with a filter

I have a page with a table présentation, connected to data through a dataset. 10 records shown.
There is a drop down used for filtering, initially set to “all records”.
100 records in the database,
So intially there are 10 pages, that you can look by using the 'pagination button included in the table présentation.
My problem occurs when, with the initial “all records” situation, you go, for exemple to page 3. Then you decide to use the filter to only display some records with a condition, with for exemple only 5 records complying.
Then, the page is still showing page 3/10 and the display is empty. The user needs to click to go back to page 1, to see the 5 records!!!
I would like to put some code in the dropdown filter change event to “force” the pagination to page 1!
How can I do that?

This is the code in the drop down change event:

export function dropdownJpn_change(event) {
console.log(event.target.value);
// reset dataset filter
let filter = wixData.filter();

let SelectedJPN = event.target.value;

if (SelectedJPN == "RESET_ALL") {
    // everything

} else {
    filter = filter.eq("refPnj", SelectedJPN);
}
console.log(filter);
$w("#datasetJPNStructure").setFilter(filter);
$w('#tableMat').'go to page 1' ???????????????
// do some extra operations
.............

}

I tested refresh(), selectrow(0), scrollTo, but without succes

Any idea

Currentpage seems to be a method for the pagination object. I am using the standard table object proposed by wix (and linked to a dataset).
With this table standard object I do not see how to adress its included pagination object.
I tested to add a normal pagination object outside the table, and linked it to the dataset, but it does not affect the table (even if I desable the table pagiation object) !
What did I missed?

Hi sentiers

Maybe this Video from the Wix Wiz will help you out:

A very good presentation of search and filter, but my problem is not there,
My problem is at the pagination level. If you are at page 3 of 10 in the full list, and apply a filter that just contains few records (less then a page), the table is blank and the paging shows 3 of 1 !!!. You have to paginate back to 1 of 1 to have the filtered data displayed !!!
A bug in the table object or is there something else to do to have it displaying the first page when you request a filter?

Ahh I see, then you’d need to use the pagination property of the table, as explained in this Doc:

So everytime a filter is applied, you should set the pagination to 1. That should solve it I guess.

UNfortunately, if I corectly understand the table/pagination there is only a few properties accessible : type and rowsperpage. I did not find any properties/method that adress the set pagination to ‘x’.
I tested different things, on both dataset and table objects, but nothing successfull
(see code below).
I think of leaving the table object and move to a repetitor! WOuld it be more simple?

$w(“#datasetJPNStructure”).setFilter(filter);

while ($w(“#datasetJPNStructure”).hasPreviousPage()) {
$w(“#datasetJPNStructure”).previousPage()
}

$w(“#datasetJPNStructure”).loadPage(1);
$w(“#datasetJPNStructure”).setCurrentItemIndex(1);
$w(“#datasetJPNStructure”).refresh()

$w(‘#tableMat’).refresh();

Why you just do not use a repeater instead of a table ?

Thats what I decided to do yesterday; and now it fully works as expected.
I understood that table object is there to be easy to implement for standard behaviour, but has limitations when you need a little bit more fonctionalities.
Thanks

1 Like