Flex ComboBox, default value and dataproviders
Solution 1
If you don't need the default item to be selectable you can use the prompt
property of ComboBox
and set the selectedIndex
to -1. That will show the string you set propmt
to as the selected value until the user chooses another. It will not appear in the list of options, however.
Solution 2
The way I've dealt with this in the past is to create a new collection to serve as the data provider for the combobox, and then I listen for changes to the original source (using an mx.BindingUtils.ChangeWatcher
). When I get such a notification, I recreate my custom data provider.
I wish I knew a better way to approach this; I'll monitor this question just in case.
mmattax
Senior Software Developer & Devops @ Formstack BS Computer Science, Purdue University Twitter: mmattax
Updated on May 29, 2020Comments
-
mmattax about 4 years
I have a Flex
ComboBox
that gets populated by adataprovider
all is well...I would now like to add a default " -- select a item --" option at the 0 index, how can I do this and still use a
dataprovider
? I have not seen any examples of such, but I can't imagine this being hard...