I was looking for a solution for this as I was using an API source and I wanted to default the dropdown option to one of the items in the returned list.
I looked in the forums and found this
However I really didn’t want to ‘hack’ the object as a text object in order to get this done, one big reason is I am displaying text (name) in the dropdown however I am using the selected object’s API id to be used for other reasons, so I was not keen on breaking my object and losing my API id for that item.
The solution for me ended up being to use States, I created a state called “Selected” and made it of the type of my API object.
Then I added a condition on the dropdown that will set the Default object to the Selected object if there is no value selected by looking at the API id.
Now on my page load (or anywhere I can set a state) I can load a specific item from the list as my defaulted item, in my case I am simply selecting item #1 in the list, however this can be any item you like.
If there is another way to dynamically load an API source and select one of the items as a default, I would love to understand how to do it. My solution works, however there are two API calls to get it done (one to load the list, the second to select an item from the list), I would love to be able to simply say in the Default property of the dropdown to select #1 (or any pos) from it’s own list once loaded, however I am sure this is not as simple as it sounds (what happens if the # selected is outside the available range, for example).
Apologies if this is an outdated solution and I am missing something obvious, however the older solution I found didn’t quite do what I needed and I may not be alone in that need, so I figured I will share what I did as a Tip.
Cheers, hope it helps someone.