Repeater-Database with 2 Referenc field to Filter

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.

You will have two include all parameters on the filter you’re setting, so not just the current one but all of them

Hello Carlos

What do you mean with “to include all parameters on the filter”?

Does nobody now how to do that? - Filtering Values from a Collection with References via two Dropdowns!

Didn’t I just explain you?

@carlosgalvarez No. I replied to you. I didn‘t understand what you explained. It is to abstract for me. :-/

@benibrodi You need to make a query first to determine which _id corresponds to each filed, for example user selects guide Mark then you’ll make a query to your guides collection to see which _id corresponds to Mark. Then filter to match that item Id.

or simply set up your drop down so that value matches _id and label is title.

@carlosgalvarez Thank you Carlos. This one was much more clear. I like very much the simple idea do use the ID as values insteat the title.

@benibrodi so you’ll have to connect label to title and value to _id