Making the "All" options work in two dropdown filters

Hi,
I am novice to wix and coding. I have two drop down filters that are connected to a dataset. One filter helps select the “genre” of paintings and the other “availability” (available, sold and on hold). Both work together for most of the options except for "All’. The "All’ Option in the “genre” dropdown or “availaibility” dropdown does not work individually or together and does not not bring back all the items I have searched this on the net and have found some discussions on resetting filters but havent been able to get results from those. Please advise and help on how i can make the "All’ Option work. Thank you in advance.

My code, which may be “totally wrong” is as follows:

import wixData from “wix-data”;
$w.onReady(() => {
});
let lastFilterGenre;
let lastFilterAvailability;
let debounceTimer;
export function dropdown1_change(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#dropdown1’).value, lastFilterAvailability);
}, 200);
}
export function dropdown2_change(event, $w) {
filter(lastFilterGenre, $w(‘#dropdown2’).value);
}
function filter(genre, availability) {
if (lastFilterGenre !== genre || lastFilterAvailability !== availability) {
let newFilter = wixData.filter();
if (genre)
newFilter = newFilter.contains(‘genre’, genre);
if (availability)
newFilter = newFilter.contains(‘availability’, availability);
$w(‘#paintingsDataset’).setFilter(newFilter);
lastFilterGenre = genre;
lastFilterAvailability = availability;
}}

//code....
 function filter(genre, availability) { 
if(genre === "all"){genre = false;}
if(availability === "all"){availability = false;}
//then the rest of your code

P.S. assuming that you set the value of the ALL option to be “all”.

Thanks a lot J.D. The code works like charm! never thought it would be so simple. Thank you very much!

You’re welcome :slight_smile: