219
Views
6
Comments
Solved
Dynamically changing dropdown list

Hello,

Is is possible to dynamically change the list used in dropdown based on a variable? For example (simplified use case):

1) I have a fruits type static entity (Apple/Orange/Pear)

2) I have 3 different entity for each of the 3 fruits (Apple/Orange/Pear)


So I would like to design my app in a way that:

1) I have a dropdown list of the fruitstype allowing the users to choose between one of the 3 fruits.


2) Based on their selection, the second dropdown's aggregate list/optiontext/optionvalue will change according to their selection. 

Example: If they were to choose Apple, the second dropdown aggregate list will become GetApple.list and the optiontext/optionvalue will change according. 

Example: If they were to choose Orange, the second dropdown aggregate list will become GetOrange.list and the optiontext/optionvalue will change according. 

Is this possible? Thank you!

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Low Nico ,

  • make a data action with 3 aggregates in it, one for each entity
  • the aggregate to execute depends on the choice made
  • output of the data action is some generic structure only containing integer for id, and name
  • refresh the data action whenever the selection of dropdown 1 changes
  • for initial, either make a default choice (like always start with apples), or set the data action as "only on demand"

Or much easier : make 3 dropdowns, each with an aggregate on another entity, and change their visibility dependant on selection.  

What of the above is more natural, also depends on what your application is going to do with the choice made

Dorine

UserImage.jpg
Low Nico

Hello Dorine,

Thank you so much, your suggestion to use data action is very helpful and I think it will solve my issue! I appreciate it!

2023-04-16 15-25-31
Krishnanand Pathak

Hi @Low Nico ,

You can use separate Dropdown for every fruit.
And set the visibility of Dropdown according to the fruit selected in first dropdown.

Regards
Krishnanand Pathak

UserImage.jpg
Low Nico

Hello, 

Thank you for your suggestion. Yeah that was my Plan B, I was just wondering if its possible to make it cleaner without having to doing the toggle visibility method

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Hi @Low Nico ,

  • make a data action with 3 aggregates in it, one for each entity
  • the aggregate to execute depends on the choice made
  • output of the data action is some generic structure only containing integer for id, and name
  • refresh the data action whenever the selection of dropdown 1 changes
  • for initial, either make a default choice (like always start with apples), or set the data action as "only on demand"

Or much easier : make 3 dropdowns, each with an aggregate on another entity, and change their visibility dependant on selection.  

What of the above is more natural, also depends on what your application is going to do with the choice made

Dorine

UserImage.jpg
Low Nico

Hello Dorine,

Thank you so much, your suggestion to use data action is very helpful and I think it will solve my issue! I appreciate it!

2025-10-14 07-47-46
Win Signo

Hello @Low Nico 

Why not have the Static(Fruit) as the Parent, and Create an Entity(FruitSelection) which contains the Fruit as reference Id. So that when you query this on the screen you need to have Fruit and FruitSelection with Filter of FruitId, so you will have the dropdown of fruit, and you just need to refresh the FruitSelection entity and it will show the list base on the fruit that you selected. In this use case, you just need to have 2 queries, 1 with filter, and two dropdown, the first is the selection of the fruit, while other 1 will just refresh the list base on your filter.

UserImage.jpg
Low Nico

Hello,

Thank you for your suggestion. However, as I mentioned, this is a simplified use case, what I actually need cant be done using your method. But thank you so much for taking the time to help with this!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.