Hi everyone, I need your expertise. I tried to search for answers in this community but unfortunately couldn't get the results I'm looking for. I need to display "no results found" when each function is clicked.
Here are my codes;
import wixData from 'wix-data';
$w.onReady(function () {
});
let lastFilter1;
let lastFilter2;
let lastFilter3;
let lastFilter4;
function filter(filter1, filter2, filter3, filter4) {
if (lastFilter1 !== filter1 || lastFilter2 !== filter2 || lastFilter3 !== filter3 || lastFilter4 !==filter4) {
let newFilter = wixData.filter();
if(filter1)
newFilter = newFilter.contains('status', filter1);
if(filter2)
newFilter = newFilter.contains('propertieType', filter2);
if(filter3)
newFilter = newFilter.contains('bedrooms', filter3);
if(filter4)
newFilter = newFilter.contains('address', filter4);
$w("#propertiesDataset").setFilter(newFilter);
lastFilter1 = filter1;
lastFilter2 = filter2;
lastFilter3 = filter3;
lastFilter4 = filter4;
}
}
export function statusDropdown_change(event, $w) {
filter($w("#statusDropdown").value, lastFilter2, lastFilter3, lastFilter4);
}
export function proptypeDropdown_change(event, $w) {
filter(lastFilter1, $w("#proptypeDropdown").value, lastFilter3, lastFilter4);
}
export function bedroomDropdown_change(event, $w) {
filter(lastFilter1, lastFilter2, $w("#bedroomDropdown").value, lastFilter4);
}
export function locationDropdown_change(event, $w) {
filter(lastFilter1, lastFilter2, lastFilter3, $w("#locationDropdown").value);
}
I agree with Gal, or another way would be to create a text field that read how many results you have, and displays above the repeater, so it would say '5 results found', or '0 results found', so they have a visual note that there is nothing to load.
you can create an updateRepeater function and call it after the filter function wherever you're using it.
function updateRepeater(){ if($w('#repeater').data.length ===0){ if(!$w('#no_results_title').isVisible){ w('#no_results_title').show() } } else{ if($w('#no_results_title').isVisible){ w('#no_results_title').hide() } } }