Dataset - SetFilter

Hi guys,

So I am working on a filter for a table at the moment and I want to filter through a Boolean inside the database for records that are either true or false.

I have been trying to do:

   $w("#ContactFormDatabaseRead").setFilter( wixData.filter()
    .ge("resolved", true)
    );

This doesn’t seem to filter the table after refreshing it?

Am I using the wrong line of code?

Hope someone can help :slight_smile:

Hi,
In this case you should use “.eq” instead of “.ge” check out the API here .
If this doesn’t solve the issue please share the entire event code.

Good luck :slight_smile:

hello there,

i have tried the same but did not work

$w("#dataset1").setFilter(wixData.filter()
                                            .eq('avaliability',true)
                                            .contains('propertyCat','Rent')
                                            .contains('propertyType',''));

avaliability is a boolean field
also
.contains(‘propertyCat’,‘Rent’) is not working !?

Please share the entire event code you are using.

$w.onReady(function ()
{
 
 //TODO: write your page related code here...
});
export function button8_click(event, $w) {
 //Add your code for this event here: 
    console.log("All");
    $w("#dataset1").setFilter(wixData.filter()
                                             .eq('avaliability',true)
                                            .contains('propertyCat','Rent')
                                            .contains('propertyType',''));
 

    $w("#button8").style.backgroundColor = "#35B6E5";
    $w("#HomeRent").style.backgroundColor = "#414141";  
    $w("#VillaRent").style.backgroundColor = "#414141";
    $w("#FarmRent").style.backgroundColor = "#414141";
    $w("#CompoundRent").style.backgroundColor = "#414141";
    $w("#RetailSpaceRent").style.backgroundColor = "#414141";
    $w("#FlatRent").style.backgroundColor = "#414141";
    $w("#BuildingRent").style.backgroundColor = "#414141";
}

You misspelled “availability”, maybe that is the problem? If not, do you get any errors?

Hello Or,
the reference to data set is correct “i spelt it wrong at the beginning”
i do not get any error , it just does not filter at all
it suppose to filter my data and show my when
propertyCat is “rent”
avaliability is true
but it show me no data at all :S
i have multiple posts non were answered it would be nice if you could assist

[SOLVED]
If you want to change the filter in code.
you need to aim for the “Fild Key” name and NOT the “Fild Name”

This is because wix dataset columns have two names.

  1. The name you have given it “Fild Name”
  2. And a database name that wix will auto generate. “Fild Key”

This is how i change my dataset filter despending on if i am on mobile or not

if(wixWindow.formFactor === "Mobile"){
// Change slideshow image filter when on mobile
$w("#Dataset1").setFilter(wixData.filter().eq("mobileOnly", true));
}