Populating a dropdown from a collection

I’m very new to Wix, just testing it out as a prospective platform for a new website. I have not written a website for 20 years or so, so I am rather rusty.

Anyway, I have what seems to be a simple process to implement, but have failed to get it working. The documentation seems to suck: it describes supporting a specific use case, without seeming to do a generic one, and it is not clear if the generic one is not possible.

So, I have a collection which holds details of our journals - comfortable over 100 of them. Given that there are a large number to scroll through, we want to be able to filter on authors of articles: just show me the journals with articles by Richard Morris. We have another collection with the authors. I want to populate the choices on a drop down with a list of authors, and use the selected author to filter the journals.

And I cannot get it to work. Please confirm that this use case is supported (though, really, it seems to be so basic that I should not have to wonder whether it is supported or not). Please then walk me through the sequence of events I have to go through to set it up.

1 Like

Hello Richard,

here you will find an example how to filter in wix…
https://russian-dima.wixsite.com/meinewebsite/blank-3

Ok, let’s do some brainstorming!

What do you ahave, what is your situation?

  1. Database-A —> “Authors” (let’s say about 20-Authors in the DB)

  2. Database-B —> “Journal-Details”

  3. Filtering-process by author.

  4. Filled DropDown (Author)

  5. Filled DropDown (Journal-Details after filtering by author)

  6. To create the “Author”-DropDown you won’t need any CODE.
    Just connect your database with the help of a dataset with your drop-down.
    You will find some options when clicking on the DropDown.
    There you will be able to chose from where (which database) you want to fill your DropDown. This will be your first step.

After you have done it, you will see all the AUTHORs in your Drop-Down you can choose. This part was completely CODE-FREE.

Your first DropDown should be ready.

  1. Filtering-process:
    To create a filter which will filter DATABASE-B (“Journal-Details”) it is necassyry, that you take a closer look, how the given example works.

Your second step would be to filter the data.

  1. And when you got your results, you can start with step-3 and try to populate the second DropDown.

Thank you for replying.

What you say seems so obvious and straight forward. But I have tried it, both before I posted my query, and in response to your reply!

When I create the Author drop down, I connect the dropdown to the dataset for Author (which has just two fields: the Title which is the key, and the Author name). I select the author name field. When I test the page (from the editor, or on the ‘live’ site), the drop down is empty, and nothing happens. To be clear, the options you get in the dialogue box is a choice of dataset, and then the field in that dataset. I select the Author dataset, and the Author name (not the key) field. When I preview the website, nothing happens, that is, the drop box is empty. [Is there any way to debug what is actually happening?] There is another option in the dialog that at this stage I have not touched. That is to ‘connect dropdown list items’. If I switch that on, I then get another request to select a dataset and field. Am I supposed to fill those in? And if so, with what? If I choose the author dataset and author name fields (again), still nothing happens: the drop down box is empty. So I am exactly where I was before: I cannot get past the first, seemingly obvious step, to be able to filter the next dataset.
At this stage, I tried to go on and test the filter anyway. But when I try to wire it up, the dialog does not let me choose the drop down box as the source of the value ti filter on, because it is already wired up to the author dataset. And if I just select the articles field ‘contains’ the value from the author dataset, I still get nothing.

So, it is not working, despite seeming to be obvious, and I really don’t know what the problem is.

Further details:
If I hard code some Author names to populate the drop down box (i.e. just type them in the settings dialogue) it works fine. But that is a nasty hack that is not really scalable as we would keep on having to edit the page definition every time we got a new author, rather than just upload the data. Things like this should be data driven, not coded.

I also tried to define a boring old text box for the user to type the name in. Wix refuses to filter on such a widget, the dialogue insisting that the thing to be filtered on must be in a dropdown. Who designs this stuff? Having the user type in what is to be used in the filter is a perfectly reasonable requirement. Hey, if I were designing this, I would allow you to define an entirely free format filter on the user side, so the user could select the field to filter on, and the comparison (equals, greater than, contains, beytween x and y, etc., etc).

Hey …

I have a tutorial about dropdowns and connections: https://www.totallycodable.com/post/dropdown-list-doesn-t-work-as-intended-or-dropdown-is-disabled

Tutorial about conditional filtering (which also shows an example on creating dropdown list via code by removing duplicates): Conditional Filtering for Dropdowns on Wix | Corvid Tutorial - YouTube

And just in case, tutorial for navigating using dropdowns (which uses examples of query and filtering): Use Dropdowns to Navigate via Dataset Filter or Query (URL text or Dynamic Page URL link field) - Tutorials - Totally Codable

If I hard code some Author names to populate the drop down box (i.e. just type them in the settings dialogue) it works fine. But that is a nasty hack that is not really scalable as we would keep on having to edit the page definition every time we got a new author, rather than just upload the data. Things like this should be data driven, not coded.
Yes you are fully right! You recognized the right way!

(equals, greater than, contains, beytween x and y, etc., etc).
All of these stuff is already given.

I would say, take the offer of Code-Queen-Nayeli (CQN) and take a look at her examples/videos, she has good explained stuff, which could help you understand things better.

Also you can take a look at my site, where i also have some examples created directly from user-questions in this forum.
https://russian-dima.wixsite.com/meinewebsite

Look for “Test-Filter” and you will find an example, which could also help you understanding all the processes a little bit better.
https://russian-dima.wixsite.com/meinewebsite/blank-3

Thank you for taking the time to respond.

I’m going to be a bit rude, sorry.

I looked at your tutorial, and to me it suffers from the same sort of issues as the official Wix help. It seems to me that it should be simple to connect a dropdown with a collection. You should specify the collection (indirectly through a dataset), and then specify the field in the collection to use as the label, and the field to use as the value (with, perhaps, the option to specify a singly field with a label,value pair, or a single field used for both the label and the value.). So what do we find in the dialogue? You get to choose the dataset, and the field for the value, with no sign of a field to specify for a label. Then there is another control to ‘connect dropdown list items’ with no explanation for what it is. But you get to specify another dataset/field pair. Frankly, I have no idea what it is for, and I have seen no documentation that tells me. I have played with it, but nothing I have tried has solved my issue.

Looking at your tutorial, you have a picture which confuses, rather than clarifies, the issue. Your description talks about a Team collection/dataset, but the picture has a default value “Who’s the best” which has nothing to do with your example. The dialogue to establish the connection does not have a ‘team’ collection/dataset but a ‘course’ one. And you do not show/explain a populated ‘value connects to’ field; nor do you explain/show the ‘connect dropdown list items’. So I am none the wiser, and still do not know what to do to get what should be a very simple thing working.

@richard28494
Never feel like you need to apologize for asking more questions when you still don’t understand something. It is ok to be confused by documentation or tutorials.

What you are looking for is not a native setting (as explained in one of my tutorials):

You cannot select 1 field for value and 1 field for label.

If you connect through dataset, you can select 1 field for both the value and the label.

If you want to set different fields for label and value, then you will have to add code to change the options.

In my conditional filtering tutorial, we populate some dropdowns by performing a query on the database, getting all the unique values then setting them as the options. Of course, we used same field for label and value.

Depending on your code experience you could modify the code to get 1 field for label and 1 field for value. (Or simply modify something else. Such as: if you want them to select a Label but then search the database for a different value then just query the value that matches that label. You can check the navigation tutorial to see how we created a query to find a URL field based on a title selected from a dropdown element. We then used the URL value to do something else: redirect to a page. You can use the value to do something else: continue searching for a different value, etc.).

If you don’t want them to use a dropdown to search, then use an text input element instead. Depending on your coding level, you can create something that searches 1 field, multiple fields, trigger on keypress, trigger on button click, auto suggest, Etc.

Sometimes, it helps when you rewrite a question in the form of a Goal and screenshot what your elements and data look like. Because it could end up being that your question is entirely different, such as: How do i create a search function for multiple fields that is triggered by a button click?

Or: I want to allow users to search my database collection, and want to allow them to search for any field. How do I do this?

Instead of: Populating a dropdown

I do not have a coding level. The last time I wrote any code professionally was over 40 years ago. I do not want to have to write code unless it is unavoidable, and even then only if it is simple and I can basically copy and paste from someone else.

So, are you saying that Wix does not support out of the box the trivial use case of populating a dropdown from a collection, and using the selected vaue from the dropdown to filter another collection? Even though there are dialogues to connect a dropdown to a collection? What are they for if not to do that sort of thing?

Of course I do not insist that the user uses a dropdown. The use case is that the user can select the author that they are interested in, and the repeater displays only the rows form the collection that have that author in it. It is easy to hard code the filter, but that is not a generic use case like we need. It is easy to hard code the options in the dropdown, which looks like a proper solution to the user, but means we have to manually maintain the content of the dropdown, which is not good.

We cannot use an ordinary text box, because Wix does not (for reasons I cannot comprehend) support that use case.

So, is there an approach that we could use that satisfies the use case, using any controls that are available? Or are we stuck with having to build static, or semi-static web pages with limited or no filtering capability for the users?

Well, stone the crows.

I have found a solution to the use case, using an entirely unexpected approach (indeed, one I was not even aware of - but then I am very new to Wix), when I was not even looking for a solution. Anyway, I started to play with Dynamic pages for our journal (having initially set up what was effectively a dynamic page manually), when I had a thought. So I created a dynamic page for the authors. And on that page, I put a repeater to display journal information. And I wired it up so that the author was used in a filter for the journal, and, to my amazement, it worked. Now, you have to select the author in that widget on the top right of the screen, not a control on the page, which people may be confused by, but it works.

I am not sure what the users will make of it, and I still have to investigate how to get to the page in a manner that users could understand. I don’t think it is as good as having a drop down on the page, because of navigation issues, but for the time being, I am going to declare victory, and wander off with a smug look on my face.


Edit. Not looking quite so smug, now. In edit mode, when testing the site, there is this handy little widget top right to navigate around the chosen authors. On the live site, there isn’t. Am now spending even more time trying to sort that out.

Sigh.

:joy:

There is no non-coded solution. You have a goal that requires coding.

If it is out of your comfort zone or you are in a time crunch then either consider hiring someone to teach you or to do the work for you. Otherwise, continue on your self-learning journey to piece your project on your own because it is possible … it just need code.

Thank you for that.

For now, we will almost certainly not attempt to deliver this, and only do static or semi-static webpages, though given that there seems to be a 100 page limit I probably have to crack dynamic pages. It is not that I am out of my comfort zone per se, but at this stage of the project, learning to code in a language that I do not know (hey, I don’t even know the name of it) to try to deliver this functionality, is much less important than getting the rest of the site up and running. I did write javascript to get my last website up and running, but that was over 20 years ago, and I did that through copy and hack.

As some stage in the future, I am likely to revisit this, hopefully with a tame (but free!) friend of a friend who can point me in the right direction.

@code-queen Actually, I have now done this without code. I used a table rather than a dropdown list, but I suspect that if I went back and tried a dropdown list again, it would probably work. Deep down there are issues of validation not mentioned in the {not very good} documentation, and the lack of any error reporting that I have found, which means you have to try trial and error. The reason the original did not work seems to be as simple as things like insisting that the names of the fields in both tables are the same. This is a restriction that I cannot see a good reason for. If you state that Field X is a reference field to table Y, then by definition, it must be to the key of table Y, and the Wix programmers could simply look up the name of that. But, no, they seem to insist that the fields in both tables have the same names. Once I worked that one out (essentially by setting up two otherwise identical instances of the approach (one working and the other not working), and then looking to see if I could spot what was different about them), then it just worked.

Hello,

I am new in wix coding however I have been working on wix websites from time to time only on non coding part, I tried few options and I was amazed what we can do with coding, I am trying to create dropdowns which will not only serve as filter but will produce data on dynamic page (in repeater). Data base will contain Image, Location, Language, Type of Activity, Product details and Price.
I am trying to populate these information on dynamic page using below dropdown filters.
Dropdowns 1)Location 2) Language 3) Type of Activity

I came across few references which are close to this thanks to @Code Queen Nayeli However I couldn’t find any thing which is really helpful, As you all are experts in this requesting some guidance…!

Thanks in Advance

Well, first of all —> you should better open your own post, with your own issue and issue-description.

  1. What’s exactly the problem?
  2. What is your aim?
  3. How is structured your project?
  4. Which elements are given?
  5. Perhaps some screenshots?

What i want to say → THE MORE INPUT = THE MORE OUTPUT.

You can link similar posts to your own one.