Clear Filter Not Working for Repeater and Drop Down Menu

Hello everyone,

I’m fairly new at using Dev Mode. That said, I’m now stumped on trying to properly reset the drop down filters and the repeater. There is something in my code that I’m not doing correctly. Could you please take a look and let me know what it is that I might be doing wrong? I also have my button ID labeled as ‘resetButton’.

I appreciate anyone taking the time to help me out.

import wixData from ‘wix-data’ ;

//USE THIS LINE OF CODE FOR BUTTON ONCLICK
// export function searchButton_click_1(event) {
// search();
// }

$w . onReady (() => {
$w ( “#dropdown1, #dropdown2, #dropdown3” ). onChange ( function () {
search ();
});
});

function search () {

wixData . query ( "VenueOwnerRegistration1" ) 
    . contains ( "country" ,  String ( $w ( "#dropdown1" ). value )) 
    . and ( wixData . query ( "VenueOwnerRegistration1" ). contains ( "stateProvinceRegion" ,  String ( $w ( "#dropdown2" ). value ))) 
    . and ( wixData . query ( "VenueOwnerRegistration1" ). contains ( "affiliatedWith" ,  String ( $w ( "#dropdown3" ). value ))) 
    //--------- COPY AND PASTE FROM THE .and() TO THE NEXT LINE TO ADD CODE FOR MORE DROPDOWN 

    . find () 
    . then ( results  => { 
        $w ( "#repeater7" ). data  =  results . items ; 
    }); 

}

export function resetButton_click ( event , $w ) {
$w ( “#dropdown1” ). value = undefined ;
$w ( “#dropdown2” ). value = undefined ;
$w ( “#dropdown3” ). value = undefined ;
$w ( “#repeater7” ). setFilter ( wixData . filter ());
}

You surely just have forget to connect the button click-function of your code with the property-panel.

Try this one instead…

import wixData from 'wix-data';

var REPEATER = "#repeater7"

$w.onReady(()=> {
  $w("#dropdown1,#dropdown2,#dropdown3").onChange(function() {search();});
  $w('#resetButton').onClick(()=>{RESET();});
});

function search() {
  wixData.query("VenueOwnerRegistration1")
  .contains("country", String($w("#dropdown1").value))
  .contains("stateProvinceRegion", String($w("#dropdown2").value))
  .contains("affiliatedWith", String($w("#dropdown3").value))
  .find()
  .then(results=> {$w(REPEATER).data = results.items;});
}

function RESET() {
  $w("#dropdown1").value = undefined;
  $w("#dropdown2").value = undefined;
  $w("#dropdown3").value = undefined;
  $w(REPEATER).setFilter(wixData.filter());
}

Thank you for getting back to me and suggesting new code for me. Much appreciated.

Line 23 (last one) gives me an error message:

“$w(…).setFilter is not a function”

Yeah, i did a mistake here…

$w(REPEATER).setFilter(wixData.filter());

Modified your code, without taking a closer look on it…

$w("#repeater7").setFilter(wixData.filter());

Now your task will be, to solve this issue…(is it really the REPEATER, you want to set the filter to ???) …by your own…