Hi,
I have a total of 7 dropdown selections plus one date picker to filter a repeater element that is linked to a collections. The filter all work. However what I am struggling is the make sure when I have used a filter that the other dropdowns only show the still valid options and not all of them. To make an example
ID Category1 Category2 category3
01 a a b
02 a b b
03 b b c
04 b c d
Let’s say I have the 3 filters where the dropdown options get populated when loading the page. Now I filter category1 and only select “a”. Before filtering, category2 had the dropdown options (a,b,c) and category3 had (b,c,d). Now I want to adjust the category2 and 3 filters so only the relevant ones are still shown.
This code here works if you have 2 filters
export function updateFilter(selectedValue, selectedValueDropDown, valueToBeUpdate,dropDownToBeUpdated){
wixData.query("myDatabase")
.contains(selectedValue, $w(selectedValueDropDown).value) // Filter
.limit(20)
.ascending(valueToBeUpdate)
.distinct(valueToBeUpdate)
.then(results => {
let distinctList = buildOptions(results.items);
$w(dropDownToBeUpdated).options = distinctList;
});
}
However I am not sure what to do if I have not just 2 filters but 7 filters as I have? When I add the 7 conditions with “.contains” or “.equal” and the filter is not selected yet, it wouldn’t work properly.
Thanks a lot!