I am having a tough time getting data in repeaters to display correctly after I apply a filter to the dataset.
You can try my sample website here.
https://svwoodturners.wixsite.com/datasetfilterbug
I have a meetings database that contains the meeting information for a whole year. I want to display the information using 2 repeaters. 1) Future meetings. 2) Past meetings.
I created 2 repeaters that display essentially the same information. The first repeater has a dataset where I apply a filter to show only meetings .ge today (new Date()) sorted low->high on date. The second repeater has a data filter that show only meetings .lt today sorted high->low on date.
The datasets point to the same database. The only difference is in their sort order. I apply the filters to the datasets in the onReady() function as follows.
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
let today = new Date ();
$w ( ‘#futureMeetingsDS’ ). setFilter ( wixData . filter (). ge ( ‘date’ , today ));
$w ( ‘#pastMeetingsDS’ ). setFilter ( wixData . filter (). lt ( ‘date’ , today ));
});
This is what I get. In the image, the browser on the left is Firefox and the one on the right is Chrome.
Even if I change the code to do a refresh as follows it does the same thing.
$w ( '#futureMeetingsDS' ). setFilter ( wixData . filter (). ge ( 'date' , today ))
. then (()=> $w ( '#futureMeetingsDS' ). refresh ())
The dataset might not yet be ready when you apply the filter. You should wrap the dataset code that you have in the page’s onReady() event handler with a dataset onReady() to ensure that the dataset is ready and available to apply the filter.
Even after wrapping it up in dataset onReady() as follows, it does the same thing.
import wixData from ‘wix-data’ ;
import wixWindow from ‘wix-window’ ;
$w . onReady ( function () {
if ( wixWindow . rendering . env === “browser” ) {
let today = new Date ();
$w ( ‘#futureMeetingsDS’ ). onReady ( function () {
$w ( ‘#futureMeetingsDS’ ). setFilter ( wixData . filter (). ge ( ‘date’ , today ));
})
$w ( ‘#pastMeetingsDS’ ). onReady ( function () {
$w ( ‘#pastMeetingsDS’ ). setFilter ( wixData . filter (). lt ( ‘date’ , today ));
})
}
});
Indeed.
I’ve passed this on to Wix Customer Care .
It does show the correct number of items ( 5 and 7 respectively). I put 12 random dates in the database. But the problem seems to be in the refresh.
You can try enabling Fetch after the page loads .
@yisrael-wix In my original website that is what I do. Fetch after the page loads. I tried that on this sample site I created too. And the results are the same.
Please feel free to edit the site if the customer care team wants to play with the code. It is something I created just to show this bug.