Hi,
I am a complete novice at coding and Corvid, so please keep that in mind when answering my question…
My problem:
I have a Repeater and a Dropdown all connected to a Collection (database?). I followed tutorials to link everything together and filter the repeater using the Dropdown. However, my issue occurs when I select a value from the Dropdown list. The page filters correctly, but I cannot filter a second time—when I click the Dropdown list again, the only option is the value that I selected initially.
My question:
How do I fix my Dropdown list so that, when I select a value the first time and my Repeater filters, I can continue to click the Dropdown and see the other filter options?
My code:
import wixData from "wix-data";
$w.onReady(function () {
});
export function industryDropdown_change(event) {
$w("#caseList").setFilter(wixData.filter().eq("industry", $w("#industryDropdown").value));
}
My problem in pictures:
This is the default view on my page:
I can filter by any of my values in my database:
Here I select “Hosting” and the code filters my Repeater correctly:
However, now when I click the Dropdown, Hosting is the only option available, instead of the other values:
Greetings, it is possible to create another dataset tied to the same collection whose only use is to be the source of the dropdown list items. The repeater and its elements are still tied to the first dataset. The filter dropdown does not need to be connected to a dataset value.
Thanks for the reply, anthonyb. I have a few naive follow up questions:
- What is the difference between a dataset and a collection? I thought those were two words for the same thing.
- Every tutorial I’ve seen only uses one dataset and connects the repeater and dropdown to it and they don’t experience the same issue I do. Is it not possible that I’m doing some really basic thing incorrectly that can be fixed without trying to “hack” a solution by creating duplicate datasets?
- I’m not sure what you mean by this: “dropdown does not need to be connected to a dataset value”. This is what my dropdown connects to:
-
Got it.
-
Got it.
-
This is the tutorial which has the code snippet I used:
https://www.youtube.com/watch?v=r0DLqkRDJ34&t=1084s
Note:
-You can see his code starting at 10:50
-His example uses 2 dropdowns. As you can see I only used the code for the first dropdown, labeled #brandDropdown in his example.
-One difference I just noticed is that he hardcodes his dropdown choices, while I connect mine to a list. Maybe that causes the issue?
Right, to avoid the problem with an approach different than what I suggested, you have to populate the dropdown either manually or through code. Connecting the list items to the same dataset that the form elements are tied to is the cause of the problem.