Repeater does not show all records in dataset after filter is cleared

I have a dataset that contains 109 records that display in a repeater. I set up 7 filters. The users can activate any combination of filters to display the items they are interested in. Four of the filters are dropdown, one is a text input box, one is a checkbox, and one is a list with checkbox selection.

The filters work great. However, when the user clears the filters, the repeater only shows 63 records. The records that it misses are consistently the same.

I downloaded a table with the list of missing records and I can’t see a pattern; my thought was that maybe a filter remains activated despite the user clearing the filter.

I added a clear all filters button that resets all the filters, and it works. I am still concerned about the fact that when only one filters is cleared, that it might not be using the other filters on the entire dataset.

This is the filter results function that I am using:

export async function filterResults ( city , mbeCert , wbeCert , vbeCert , keyword , capabilities , categories ){

**var**  newFilter  =  wixData . filter (); 
//console.log("City: " + city + " -- MBE: " + mbeCert + " -- WBE: " + wbeCert + " -- VBE: " + vbeCert + " -- keyword: " + keyword + " -- CS: " + capabilities + " -- categories: " + categories + "."); 
newFilter  =  newFilter . eq ( 'city' ,  city ); 
newFilter  =  newFilter . eq ( 'mbe' ,  mbeCert ); 
newFilter  =  newFilter . eq ( 'wbe' ,  wbeCert ); 
newFilter  =  newFilter . eq ( 'vbe' ,  vbeCert ); 
newFilter  =  newFilter . contains ( 'businessName' ,  keyword ); 
newFilter  =  newFilter . eq ( 'cs' ,  capabilities ); 
newFilter  =  newFilter . hasSome ( 'category' ,  categories ); 

**await**  $w ( "#dbCompanies" ). setFilter ( wixData . filter ()); 
$w ( "#dbCompanies" ). setFilter ( newFilter ) 

lastCity  =  city ; 
lastMbeCert  =  mbeCert ; 
lastWbeCert  =  wbeCert ; 
lastVbeCert  =  vbeCert ; 
lastKeyword  =  keyword ; 
lastCapabilities  =  capabilities ; 
lastCategories  =  categories ; 

}

And this is one of the filter functions:

export function iptCity_change ( event ) {
var adjCity ;
if ( $w ( “#iptCity” ). value !== ‘.ALL’ ){
adjCity = $w ( “#iptCity” ). value ;
}
filterResults ( adjCity , lastMbeCert , lastWbeCert , lastVbeCert , lastKeyword , lastCapabilities , lastCategories );

}

This is the code for the clear all button:

export function btnClearFilters_click ( event ) {
$w ( “#iptMBECert” ). selectedIndex = undefined ;
$w ( “#iptWBECert” ). selectedIndex = undefined ;
$w ( “#iptVBECert” ). selectedIndex = undefined ;
$w ( “#iptCity” ). selectedIndex = undefined ;
$w ( “#dbCompanies” ). setFilter ( wixData . filter ());
}

Thank you in advance for your help in fixing the individual filter clearing issue.

“However, when the user clears the filters, the repeater only shows 63 records”
What function do you call in this case?

In this case (for this filter) it is the iptCity_change(event) function. If the user selected anything other than .ALL then it clears the filter. I realize now that the code as written does not do that. I need to add an else statement.

Could you agree?

Thank you.

Change your filterResults function like this:

//..
var newFilter=wixData.filter();
if(city){newFilter = newFilter.eq('city',city);}
if(mbeCert){newFilter = newFilter.eq('mbe', mbeCert);}
//do it for all the function arguments.