Hello Community,
first of all, thank you very much for your input, I have learned so much on this platform it is incredible.
I have/had absoluteley no knowledge of coding hence my decision to use WIX for my website and thanks to Corvid I could even learn a bit of coding.
I am facing this issue which I found actually a lot of times here but I never managed to make the answers work on my own code.
So I thought maybe I post my code here and someone can help me.
Situation:
I have a database with items. These items have two values. Colour and Fabric. (Dont be confused, the fiedkey for my fabrics is “price”. Was an accident :D)
The database is displayed via repeater.
I have two dropdown menues with each the values.
Now the problem. It does not matter which dropdown menu I use first, the repeater is successfully displaying me the filtered results.
But then I use the second dropdown to “filter it even more” it just disregards the first filter and just shows me all items which suit to the second filter.
How can I do it, that the second or maybe future third and forth dropdown filter always “refines” the current search, therefore “puts another filter on top” rather then acting alone and disregarding the other filters.
I hope someone can help me and tell me exactly where I need to add which code. As mentioned, I just started learning code so please explain so I can understand you
Thanks in advance!
Here my code:
import wixData from ‘wix-data’ ;
$w.onReady( function () {
});
export function dropdown1_change(event, $w) {
$w( "#dynamicDataset" ).setFilter(wixData.filter()
.contains( "colour" , $w( '#dropdown1' ).value))
.then((results) => {
$w( "#listRepeater" ).data = results.items;
});
$w( “#listRepeater” ).expand();
let colourFilter = $w( ‘#dropdown1’ ).value;
if (colourFilter === “Any” ){
$w( ‘#dynamicDataset’ ).setFilter(wixData.filter());
}
}
export function dropdown2_change(event, $w) {
$w( "#dynamicDataset" ).setFilter(wixData.filter()
.contains( "price" , $w( '#dropdown2' ).value))
.then((results) => {
$w( "#listRepeater" ).data = results.items;
});
$w( “#listRepeater” ).expand();
let fabricFilter = $w( ‘#dropdown2’ ).value;
if (fabricFilter === “Any” ){
$w( ‘#dynamicDataset’ ).setFilter(wixData.filter());
}
}