How to set flex ComboBox prompt property to empty string
Here is my code:
<mx:ComboBox prompt="" editable="true" dataProvider="{tableSelector.list}"/>
When this code executes, flex just sets the selectedIndex to 0 and displays the first item in the dataProvider instead of leaving the text and prompt as the empty string "". How do I get around this? I need the text property to be "" unless the user selects anoth开发者_开发问答er item in the combobox.
I would recommend not using the mx ComboBox and use the Spark equivalent instead. A way to fix this with the mx combobox would be to just use a space or use actionscript to set it because of the way mxml parses string info into properties. An empty string is essentially equal to null in mxml.
I would question as to why you need an empty combobox to start with. You might want to just use an empty item in the dataprovider instead.
I was able to fix this without modifying the dataProvider with this code:
combobox1.dataProvider = tableSelector.list;
combobox1.selectedIndex = -1;
+J_A_X answer, and check
requireSelection="false"
which is valid for Spark DropDownList ...
精彩评论