Hi Wix-Forum
I try to Filter a List with those 2 referenced row .
For that I have 2 Dropdown (Responsable is for Guide & Region for Region)
and 1 Dataset that is connected to the List
To fill out the Dropdowns is use this Code and that works perfect:
$w.onReady(() =>{
loadRegion();
loadGuide();
});
function loadRegion(){
wixData.query('Region')
.find()
.then(res =>{
let options = [{"value": '', "label": 'Alle Regionen'}];
options.push(...res.items.map(regions => {
return {"value": regions.title, "label": regions.title};
}));
$w('#dropdownRegion').options = options;
});
}
function loadGuide(){
wixData.query('GuidesDB')
.find()
.then(res =>{
let options = [{"value": '', "label": 'Alle Guides'}];
options.push(...res.items.map(regions => {
return {"value": regions.title, "label": regions.title};
}));
$w('#dropdownGuide').options = options;
});
}
And the Code for the Filter:
let lastFilterGuide;
let lastFilterRegion;
export function dropdownRegion_change(event){
filter(lastFilterGuide, $w('#dropdownRegion').value)
}
export function dropdownGuide_change(event) {
filter($w('#dropdownGuide').value, lastFilterRegion)
}
function filter(guide, region){
if(lastFilterGuide !== guide || lastFilterRegion !== region){
let newFilter = wixData.filter();
if(guide){
newFilter = newFilter.contains('responsable', guide);
}
if(region){
newFilter = newFilter.contains('region', region);
}
$w('#datasetCollection').setFilter(newFilter);
lastFilterRegion = region;
lastFilterGuide = guide;
}
}
But if I choose something out of one of the Dropdowns everything dissapear and the List is blank - so the filter is not working.
I have read that referenced field so not working, how can I fixt that?
Hope someone can help.