Problem in filtering with multi search

Facts :

  • i have this search section over here .
  • it works just fine i can multi search with this section by name and dropdown and date .

  • this button over her its job to to clear the inputs (input.value = undefined) .

problem :

i can not search with one input , i have to fill all inputs so that results appear
i want that the user can search by name only or dropdown only or date only
and if the user want to multi search he can do it also

this is my code :


$w('#dataset1').setFilter(wixData.filter().eq("_owner", ii))
    $w('#dataset2').setFilter(wixData.filter().eq("_owner", ii))

    $w('#button16').onClick(() => {

        $w('#image4').show()
        setTimeout(() => { $w('#image4').hide() }, 750)
        $w('#dataset1').setFilter(wixData.filter().eq("_owner", ii).eq("date", $w('#appdatePicker2').value).eq("doc", $w('#dropdown2').value).contains("patient", $w('#input2').value).or(wixData.filter().eq('phone', $w('#input2').value)))
        $w('#dataset2').setFilter(wixData.filter().eq("_owner", ii).eq("date", $w('#appdatePicker2').value).eq("doc", $w('#dropdown2').value).contains("patient", $w('#input2').value).or(wixData.filter().eq('phone', $w('#input2').value)))

    })
    

    $w('#button17').onClick(() => {
        $w('#image4').show()
        setTimeout(() => { $w('#image4').hide() }, 750)
        $w('#appdatePicker2').value = undefined
        $w('#input2').value = undefined
        $w('#dropdown2').value = undefined
        $w('#dataset1').setFilter(wixData.filter().eq("_owner", ii))
        $w('#dataset2').setFilter(wixData.filter().eq("_owner", ii))

    })

any help will be appreciated
thanks for reading…

Hello!

First please when you write code name your elements better. Do not use default names like “button17”

Can you share the page with us if you can (link of this page to test it live and see the code)

@loeix
i am very sorry about the default name and i will not do this mistake again .

and that is the link of the site:
mysite

and i made a test account for you :
Email : loeix@hotmail.com
Pasword: 0000

click on patient page :

then click on appointment :

one more thing while you test the site take a look at this message in the inspect :

and thank you soo much

@yaser1999yaser These warnings are caused from other codes (not your codes) and these are not important things. If you are using AdBlock close it.

Reason that you see this problem is because of undefined or null data being filtered at the same time.

When I test I can’t see any results even if I filter everything. So for now it’s just not working completely on my end.

@loeix

it is working
here is the proof

maybe you selected a date that not added to the appointment(try 20/05/2022 - 21/05/2022)

anyway is there is a way that i can exclude the null or undefined from filters ?

@yaser1999yaser I tried these dates it’s not working on me because probably you filter the owner field.

Yes there is a way you need to create a dynamic filter system which you need to check the value of the input if it’s undefined you will bypass the filter if it’s not you will filter it. That’s the logic you can create and you can check this example:

Mega Search (wix.com)

@loeix
i did it
thank you

but i need one more favor to ask

i do not why the filter did not work with you can you help understand why
because i am afraid that the filter do not work with other users