2
votes

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 another item in the combobox.

3

3 Answers

4
votes

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.

1
votes

I was able to fix this without modifying the dataProvider with this code:

combobox1.dataProvider = tableSelector.list;
combobox1.selectedIndex = -1;
0
votes

+J_A_X answer, and check

requireSelection="false"

which is valid for Spark DropDownList ...