Hi, We would like to filter a word in a list linked to a database collection.
We watched the following video.
We tried out the given codes, but unfortunatly there are several error notifications when we put in this code edited with our own informations.
Our Code was like
import wixData from “wix-data”
$w.onReady(function () {
//TODO: write your page related code here…
});
//filter to Istanbul
export function Istanbul_onclick() {
//Add your code for this event here:
}console.log(“filtering items to Istanbul”);
$w(#“Listings”).setFilter(wixData.filter().contains(“City”,“Istanbul”))
.catch(error)=> (
let errorMsg = error.message;
let code =error.code;)
}
I tried many different versions, but with the selection of my “listings” data says that"listings is not a valid selector name and so on.
I don`t know how to make this function. Could you please help?
Hi Este,
You should get rid of the quotes around the element name:
Not this:
$w(#“Listings”).setFilter(wixData.filter().contains(“City”,“Istanbul”))
But this:
$w(#Listings).setFilter(wixData.filter().contains(“City”,“Istanbul”))
That might be your problem. If that doesn’t help, let me know.
Good luck,
Yisrael
I have similar problem with trying to filter a collection using code in the API. My code is:
$w(“members_table”).setFilter( wixData.filter().contains(“title”, myValue))
This was copied and pasted from the Wix API documentation and keeps giving me the error:
unknown character at position 8.
Please help, I can’t move forward with dev untill this is solved
Hi Stephen,
Welcome to WixCode.
It appears that you are attempting to apply a filter to a table (members_table), however the filter should be applied to the appropriate dataset. Something like this:
$w("#members_dataset").setFilter( wixData.filter().contains("title", myValue))
Note: Elements are referenced by usig the full name including a hashtag (#). For example: reference the dataset by using the name #members_dataset, and reference the table with the name #members_table. I just made up those names. In my example, you will need to substitute the name of your dataset.
Good luck,
Yisrael
Trying to use this is a situation where I have a dataset that I would like to filter by State upon clicking a button and only show those states.

I fixed the wixData issue there… but lost as to what to do to try and get this to filter by State. There are all entered as Text data types and two letter (ex. FL or GA). If I add a filter to the page by State and select manual value and type FL in there that works, but want that functionality hanging off of the button
Please help!
Here is an example of a form that should be helpful.
thank you very much… having an issue as it will not let me save the site and it is asking me to do that whenever I enable Corvid. I have done all of the steps that it recommends to fix that to no avail! Any other way I can take a look at this?