Filtering a dataset based on a text value and a boolean

I’m filtering a dataset based on a user input and a boolean value. When I just filter by the user input (.contains(“txtAddresses”, title)), it works fine, but when I add the filter for the boolean (.eq(“addCustomer”, false)) it breaks and the repeater doesn’t show anything. I’m really confused and don’t know why it does this. Any help would be greatly appreciated!

My website: https://editor.wix.com/html/editor/web/renderer/edit/c3ce1a2e-10be-429f-a16c-f968c015b8c5?metaSiteId=55d3d8d0-a4d9-41ff-95e6-ed0dbd262842&editorSessionId=0a00874a-9cdc-4b89-b999-754db948fd25&referralInfo=dashboard

It’s on the Addresses (Addresses) dynamic page.

Hi,

I add a button event handler that filter the dataset according to ‘addCustomer’ and its seems to be working,
Can you explain how did you try to implement the filter?

Best,
Sapir

Hi Sapir,

Sorry, I didn’t explain what I was trying to do very well. I want the dataset to always be filtered for when the customer boolean is false and to never show the items where the boolean is true. I don’t want it to be optional for the user, because I’m showing the other results on a separate page. Does that explain better?

Hi,

Use onReady() function in order to permanently set a filter in your dataset.

  $w("#normDataset").onReady(() => {
    $w("#normDataset").setFilter(wixData.filter().eq('addCustomer', false));
    });
  

Best,
Sapir

Hi, I found this thread close to solving my issue. My case varies as follows;

I have dropdown filters run by velo code. This overwrites the filters set via dataset settings, whenever a dropdown option is selected. How do I maintain a boolean filter fixed always?

(I have several DD filters combined, I’ve shown only one below)

import wixData from 'wix-data';

$w.onReady(async function () {
    await setupCountriesDropdown();
    setupSubjectDropdown();
});

function setupSubjectDropdown() {
    $w("#subjectDropdown").onChange(filterAndApply);
}

async function filterAndApply() {
    let filter = wixData.filter();

    const subject = $w("#subjectDropdown").value;
    if (subject) {
        filter = filter.ge("subjects", subject);
    }

    $w("#listingsDataset").setFilter(filter);
}

Hi, I found this thread close to solving my issue. My case varies as follows;

I have dropdown filters run by velo code. This overwrites the filters set via dataset settings, whenever a dropdown option is selected. How do I maintain a boolean filter fixed always?

(I have many DD filters combined, I’ve shown only one below)

import wixData from 'wix-data';

$w.onReady(async function () {
    await setupCountriesDropdown();
    setupSubjectDropdown();
});

function setupSubjectDropdown() {
    $w("#subjectDropdown").onChange(filterAndApply);
}

async function filterAndApply() {
    let filter = wixData.filter();

    const subject = $w("#subjectDropdown").value;
    if (subject) {
        filter = filter.ge("subjects", subject);
    }

    $w("#listingsDataset").setFilter(filter);
}