[SOLVED] Database filtering repeater breaks on page turn

Hello! Hope you guys are doing well.

I’m having 2 problems I’m in the middle of trying to solve, and could use some help. I have multiple dropdowns filtering a repeater. (See video for more)
Problem 1: Once a filter is set and you turn the page (pagination set at bottom of repeater), the filter breaks.
Problem 2: Once a filter is set, it stops using my database sort order. Any advice of what to do to solve these? Thanks!
(*I’ll post my code below video)

import wixData from ‘wix-data’ ;

$w . onReady (() => {
$w ( “#dropdown1, #dropdown2, #dropdown3, #dropdown4, #dropdown5, #dropdown6, #dropdown7, #dropdown8, #dropdown9, #dropdown10, #dropdown11, #dropdown12, #dropdown13, #dropdown14,” ). onChange ( function () {
search ();
});
});

function search ( ) {
wixData . query ( “Types” ). contains ( “od” , String ( $w ( “#dropdown1” ). value ))
. and ( wixData . query ( “Types” ). contains ( “ie” , String ( $w ( “#dropdown2” ). value )))
. and ( wixData . query ( “Types” ). contains ( “ft” , String ( $w ( “#dropdown3” ). value )))
. and ( wixData . query ( “Types” ). contains ( “ns” , String ( $w ( “#dropdown4” ). value )))
. and ( wixData . query ( “Types” ). contains ( “deciders” , String ( $w ( “#dropdown5” ). value )))
. and ( wixData . query ( “Types” ). contains ( “observers” , String ( $w ( “#dropdown6” ). value )))
. and ( wixData . query ( “Types” ). contains ( “sp” , String ( $w ( “#dropdown7” ). value )))
. and ( wixData . query ( “Types” ). contains ( “cb” , String ( $w ( “#dropdown8” ). value )))
. and ( wixData . query ( “Types” ). contains ( “fmS” , String ( $w ( “#dropdown9” ). value )))
. and ( wixData . query ( “Types” ). contains ( “fmDe” , String ( $w ( “#dropdown10” ). value )))
. and ( wixData . query ( “Types” ). contains ( “16Type” , String ( $w ( “#dropdown11” ). value )))
. and ( wixData . query ( “Types” ). contains ( “32Type” , String ( $w ( “#dropdown12” ). value )))
. and ( wixData . query ( “Types” ). contains ( “class” , String ( $w ( “#dropdown13” ). value )))
. and ( wixData . query ( “Types” ). contains ( “fm” , String ( $w ( “#dropdown14” ). value )))

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

}
//Reset Filter
export function resetButton_click ( event ) {
$w ( “#dataset2” ). setFilter ( wixData . filter ())
$w ( “#dropdown1” ). value = undefined ;
$w ( “#dropdown2” ). value = undefined ;
$w ( “#dropdown3” ). value = undefined ;
$w ( “#dropdown4” ). value = undefined ;
$w ( “#dropdown5” ). value = undefined ;
$w ( “#dropdown6” ). value = undefined ;
$w ( “#dropdown7” ). value = undefined ;
$w ( “#dropdown8” ). value = undefined ;
$w ( “#dropdown9” ). value = undefined ;
$w ( “#dropdown10” ). value = undefined ;
$w ( “#dropdown11” ). value = undefined ;
$w ( “#dropdown12” ). value = undefined ;
$w ( “#dropdown13” ). value = undefined ;
$w ( “#dropdown14” ). value = undefined ;
}

1 Like

You should set sort using code instead of the wix dataset panel.

You should do filter to the dataset, instead of querying and apply data to repeater.

Thank you for this! I have someone working on this project today, so hopefully they will be able to get that code working.