Multiple filters with wix velo

Hello all,

I’ve already created a code to filter my dataset/ repeater by different selection tags.
I also want to add 2 dropdown menus to further filter the dataset/ repeater. I am an absolute beginner with wiz velo, so i really don’t know where to add the extra code.

Could somebody please help me with this issue?

That’s the actual code I‘ve got so far:

import wixData from ‘wix-data’;

const collectionName =‘Jobs’;
const fieldToFilterByInCollection = ‘Tags’;

$w.onReady( function () {

setRepeatedItemsInRepeater(); 
loadDataToRepeater(); 

$w('#Tags').onChange((event) => { 
    **const**  selectedTags = $w('#Tags').value; 
    loadDataToRepeater(selectedTags); 
}) 

});

function loadDataToRepeater(selectedCategories = ) {

**let**  dataQuery = wixData.query(collectionName); 

**if**  (selectedCategories.length > 0) { 
    dataQuery = dataQuery.hasAll(fieldToFilterByInCollection, selectedCategories); 
} 

dataQuery 
    .find() 
    .then(results => { 
        **const**  itemsReadyForRepeater = results.items; 
        $w('#Jobs').data = itemsReadyForRepeater; 
        **const**  isRepeaterEmpty = itemsReadyForRepeater.length === 0 

        **if**  (isRepeaterEmpty) { 
            $w('#resultsnotfound').show(); 
        }  **else**  { 
            $w('#resultsnotfound').hide(); 
        } 
    }) 

}

function setRepeatedItemsInRepeater() {

$w('#Jobs').onItemReady(($item, itemData) => {}) 

}

I haven’t read your code, but one mistake just popped-up:
A field key in database collection never starts with a capital letter. You probably used the field name (/field label) instead of the field key.
Try to fix it, and if there’re other issues, write it here.

thank you!
the code above works fine, even though the fieldkey starts with a capital letter, but I will change it!

I want to ask where I have to put in another code to filter a dropdown menu.

So to clarify: I want to add dropdown menus to my existing selection tags, but i’m not sure how to code them so that the filter works.

Is there any chance you can help me with that?

Somethin like:

import wixData from 'wix-data';
function queryData(){
 let query = wixData.query(collectionName);
 const selectionTagsVal = $w('#selectionTags').value;
 const dropdownVal = $w('#dropdown1').value;
 if('#selectionTags').value?.length)[
  query = query.hasAll(fieldToFilterByInCollection, selectedCategories);
 }
 if(dropdownVal){
  query = query.eq('field', dropdownVal);
 }
 query.find()
.then(r => {
 //continue with your code
 })
}

$w.onReady(() => {
 $w('#selectionTags, #dropdown1').onChange(queryData);
})

(this is the way to do it with a direct query, but you can also filter a dataset instead)