Chained Conditional Filtering Dropdown

Hi everyone!
I’ve already created and coded together all my dropdowns (I have 5 of them), and set the database.

The problem is that each dropdown filters only the closest one that precedes it, so I can’t create a specific chain of choices.
Is it possible to code that all the dropdowns that follow the first verify that the items follow a specific sequence?

For example: 3 raws in the database:
Shoes Color Number Price

  1.  A                Blue                  40                   99 
    
  2.  B                Blue                  41                   50 
    
  3.  C               White                 40                   29 
    

I want to choose the first raw, but the dropdown I have do this:
A → (A) → Blue → (Blue) → 40 → and so on.
B White 41
C

I don’t want both numbers (infact 41 is not linked to all of the previous choices, infact, it doesn’t exist 41 shoes of A type)!
What I want is that the dropdown recognises, verifies and shows me only the choices linked with only the specific items in the sequence.
A → Blue → 40 → 99 (for example).

Thanks Everybody for the support.

Hi Teoteogo,

In code there are always multiple approaches of solving a problem.
One way you can use is creating a different dataset for each dropdown and use the setFilter function
to filter only the items that share the previous dropdown’s value,
for example:

export function dropdownShoes_change(event) { $w(“#colorDataSet”).setFilter(wixData.filter() .contains(“shoes”,$w(“#dropdownShoes”).value) ) }

I recommend reading more about setFilter and wixDataQuery for more information

https://www.wix.com/code/reference/wix-dataset.html#setFilter
https://www.wix.com/code/reference/wix-data.WixDataQuery.html

Good Luck!

1 Like