lukevb
October 8, 2020, 2:57pm
1
I have this code at the moment:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#searchButton").onClick(()=>{
$w("#propertiesDataset").setFilter(wixData.filter()
.eq("status", $w("#dropdown").value)
.eq("address", $w("#search").value));
});
I am trying to make it so that users can use a radio button, and a search bar to filter for items in the database, but when I take out the second .eq line it works.
Where am I going wrong?
Hi !!!
Try this →
$w . onReady ( function () {
$w ( “#searchButton ” ). onClick ((event) => {
$w ( “#propertiesDataset ” ). setFilter ( wixData . filter ()
. eq ( “status” , $w ( “#dropdown ” ). value )
. eq ( "address" , $w ( "#search" ).value);
)
});
});
lukevb
October 8, 2020, 3:57pm
3
Hey,
Thanks for the response. This doesnt seem to be working as it is saying
“Parsing error: Unexpected token wixData” on the wixData . filter ()
@lukevb yeah !!!
Place the below code on the above of all your code
import wixData from ‘wix-data’;
lukevb
October 8, 2020, 4:02pm
5
@ajithkrr This is already there, so all my code is as follows:
import wixData from 'wix-data';
$w.onReady(function () {
$w("#searchButton").onClick(()=>{
$w("#propertiesDataset").setFilter(wixData.filter()
.eq("status", $w("#dropdown").value)
wixData.filter()
.eq("address", $w("#search").value);
});
})
Try this →
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( “#searchButton ” ). onClick ((event) => {
$w (“# propertiesDataset” ). setFilter ( wixData . filter ()
.eq( “status” , $w ( “#dropdown ” ). value )
.eq( “address” , $w ( “#search ” ). value )
)
});
});
lukevb
October 8, 2020, 4:27pm
7
Weird, nothing comes up. I think thats the same code as OP?
lukevb
October 8, 2020, 4:56pm
9
@jonatandor35 If i take
.eq("address", $w("#search").value)
Out of the code, it works fine with the radio buttons, which is the #dropdown , but as soon as I add in the address search in it no longer works.
@lukevb Try using. contains
.contains ( “address” , $w ( " #search " ). value )
lukevb
October 9, 2020, 8:38am
11
@ajithkrr So I have made sure there is an item which will filter when filtering using this code.
Just nothing comes up.
My code is now:
import wixData from ‘wix-data’ ;
$w.onReady( function () {
$w( “#searchButton ” ).onClick(()=>{
$w( "#propertiesDataset" ).setFilter( wixData.filter()
.eq( "status" , $w( "#dropdown" ).value)
.contains( "address" , $w( "#search" ).value))
});
});
lukevb
October 9, 2020, 8:46am
12
EDIT:
It works… But only with certain searches… Like searching SL8 brings up results, but HP10 does not…