Hi I have a code that filters categories but I need to see all options this is my code please help.
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( '#dropdown1' ). onChange (() => {
**const** selectedTag = $w ( '#dropdown1' ). value ;
**let** filter = wixData . filter ();
**if** ( selectedTag . length > 0 ) {
filter = filter . hasSome ( "subtitle" , selectedTag );
}
$w ( '#dataset1' ). setFilter ( filter );
})
});
please tell me where to add, thanks in advance
It is not clear what you are trying to achieve.
How do look like your related DATABASE-STRUCTURE?
What does mean…
…I need to see all options…
…???
What about something like that …
import wixData from 'wix-data';
let selection1, selection2, selection3;
$w.onReady(function () {
$w('#dropdown1').onChange(()=> {selection1=$w('#dropdown1').value, check();})
$w('#dropdown2').onChange(()=> {selection2=$w('#dropdown2').value, check();})
$w('#dropdown3').onChange(()=> {selection3=$w('#dropdown3').value, check();})
});
function check() {let filter = wixData.filter();
if (selection1) {filter=filter.hasSome("subtitle", selection1);}
if (selection2) {filter=filter.hasSome("subtitle", selection2);}
if (selection3) {filter=filter.hasSome("subtitle", selection3);}
$w('#dataset1').setFilter(filter);
}
Not tested → just some theoretical thoughts.
Now i think i understand what you are searching for.
You simply need a RESET-FILTER-OPTION right?
$w("#myDataset").setFilter( wixData.filter());
yes reset option please where do i put this is my code?
Try this one…
import wixData from 'wix-data';
$w.onReady(function() {
$w("#myDataset").onReady(()=>{
$w("myResetButtonIDhere").onClick(()=>{
$w("#myDataset").setFilter(wixData.filter());
});
});
});
Here you will find much more information about how to work with DATASET-FILTERING…
https://www.media-junkie.com/pflegeservice