Hi ,
any one help in this regard,
having table with 5/6 column and want filter with & condition,
individual filter working fine
when run code there is no error but filter based on second condition, i.e brand , i want both conditon
export function input8_change ( event ) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
const ram = wixData . filter (). contains ( “ram” , $w ( “#category” ). value )
const storage = wixData . filter (). contains ( “storage” , $w ( “#brand” ). value )
$w ( “#dataset1” ). setFilter ( ram && storage );
console . log ( ‘done’ );
@info60561
You’re on the right track attempting to chain filter statements together, but there is a syntax issue with the above. Try this approach instead.
let ram,storage;
let filter = wixData.filter();
ram = $w("#category").value;
storage= $w("#brand").value;
if (ram){
filter = filter.contains("ram", ram);
}
if (storage){
filter = filter.contains("storage",storage);
}
$w("#dataset1").setFilter(filter)
.then(() => {
console.log("Dataset is now filtered.");
})
Hi ,
@ anthonyb
Thanks for your code,
it will fine and work as we desire , we added multiple column in this and work fine , thanks
let ram , storage , brand , processor , graphics , display , price ;
let filter = wixData . filter ();
processor = $w ( “#input10” ). value ;
ram = $w ( “#input11” ). value ;
storage = $w ( “#input12” ). value ;
graphics = $w ( “#input13” ). value ;
display = $w ( “#input14” ). value ;
price = $w ( “#input15” ). value ;
brand = $w ( “#input16” ). value ;
if ( processor ){
filter = filter . contains ( “processor” , processor );
}
if ( ram ){
filter = filter . contains ( “ram” , ram );
}
if ( storage ){
filter = filter . contains ( “storage” , storage );
}
if ( graphics ){
filter = filter . contains ( “graphics” , graphics );
}
if ( display ){
filter = filter . contains ( “display” , display );
}
if ( price ){
filter = filter . contains ( “price” , price );
}
if ( brand ){
filter = filter . contains ( “brand” , brand );
}
$w ( “#dataset1” ). setFilter ( filter )
. then (() => {
console . log ( “Dataset is now filtered.” );
})
}