Hello, I need help connecting a table and dropdown menu to a dataset.
I have been following some posts on this forum and youtube troubleshooting but I am not understanding why It is not working.
This is my code
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixData from ‘wix-data’ ;
//This function replace the for loop:
$w.onReady(() => {
wixData.query( ‘carmakes’ )
.find()
.then(res => {
let options = [{ “carMake” : ‘’ , ‘same’ : ‘All carmakes’ }];
})
});
export function dropdown1_click(event) {
console.log($w( ‘#dataset1’ ));
filter($w( ‘#dropdown1’ ).value);
}
function filter (title) {
$w( ‘#dataset1’ ).setFilter(wixData.filter().contains( ‘carBrand’ , title));
}
If you need me to link to the website or any information about asset names etc let me know.
Any help would be greatly appreciated.
Kind regards
Hi isaac,
are your names from title the same as the dropdown value?
the dropdown has 2 fields Label and Value.
dropdown.value takes the value part (starting with lowercase)
if your title in your dataset starts with a capital letter it won’t work.
kristof.

Hey Kristof Thanks for getting back to me,
Ill attach a screenshot of the labels of everything now
Hi @isaacgannon23 ,
i didn’t see the problem first but its clear now.
in your on ready code you go check for evrything in the database “carmakes”
but you don’t do anything with the value.
also the pictures with “Field name”, “Field key”," Field type" are these from the database?
ifso your “FieldName = Size” has a “Field Key = same” ?
anyway the next code should work without needing a dataset since it goes straight to your database (wixData.query)
This code will show a full list of evry brand and the size of it:
wixData.query('carmakes')
.find()
.then(res => { // res are all your items from the database
let options = [{"carMake": '', 'same': 'All carmakes'}];
for (var i = 0; i < res.length; i++) {
options.push({"label": res[i].carBrand, "value": res[i].same});
$w("#dropdown1").options = options; //
}})
})
normaly you also can just connect your dataset to your dropdown without code.
i also just readed you needed to connect the dataset/database to a table.
what exactly do you want to show in the table?
kristof.
@volkaertskristof Hey Kristof,
Thanks for your help. This is my first Wix project so when I was assigning values I didn’t really understand the impact of them. What I want to show in the table are the car make(Prius) and the size (s/xs) and I want this to be selected by the drop-down filter by the car brands(Toyota). The images of “Field name”, “Field key”," Field type"
Thanks a lot for your help.
Isaac
@isaacgannon23
oke so if you use my code you will get a huge list of items in your dropdown that aren’t needed there.
what you will need to do is just manualy add label and value to your dropdown
or make a seperate database with only carbrands and size. that you only have 1 of them.
(now you will have a few times volvo a few time citroën etc…)
that done, connect your dataset1 to your table without code.
you should be able to connect each field properly that way.
make sure the dataset is read only.
then your filter data should work aslong as the added values in the dropdown are the same as the values to compare in the dataset
kristof.
@volkaertskristof
So I added the code to the web page and it comes up with this
parsing web-module ‘public/pages/enufv.js’: Unexpected token (11:7) while parsing file: public/pages/enufv.js
then when I remove the last “})” of your code the drop-down still doesn’t connect. Is there some setting I may have to apply to the dropdown menu?
Isaac
I will add the labels manually to the drop down list. I think I miss understood what you said. My apologies.
Let me know how it goes
if it doesn’t work as needed i can always take some time to make a small image example.
kristof.
@volkaertskristof Hey
I’m running into an issue now where all of the values show up in the preview then once I select a different drop-down item it doesn’t load any values. Any ideas on where I’m going wrong?
can you show me in an image what you exactly mean?
you can do it without a single line of code.
Add a dataset , Dropdown, table :
Add your choices to your dropdown :
Connect your dataset with your table.
the row Title will be added aswel but you can just go to table content and remove it from the list.
add filters to your dataset.
where you select Field CarBrand(Tekst) you have to filter on the sort on brand dropdown.
Where you select Field Size(tekst) you have to filter on the Sort on Size dropdown.
This works for me:
Hey again, I tried to follow those steps and i think i did the exact same but I still am having the same issue where it wont load. I will try it without the code and see if it works
This is what the table looks like when the page initially loads then it goes blank to the previous one above after I try to change the dropdown menu filter.
@volkaertskristof Hey thank you so much I just added you so you can remove your email Sorry I am busy for the next hour. I appreciate this alot thank you for taking your time to help !
@isaacgannon23
no problem.
i added it to your website.
i sa you had a dynamic dataset.
they don’t work the same as a normal dataset so i adjusted where needed.
so i added a small amount of code to make it work.
If you have any further questions.
let me know.
Hi, thanks for the guide! Can i use this filtering system for PRICE with a bar for user?
es. —-|—
<10.000€
10.000€<20.000€
20.000€<50.000€
thanks
luca
Hi lucasai
i’m glad you liked the guide.
can you make a new question post so we do not bump this question.
i will take a look when i have the time.
kristof.