0

Ok what I want is quite typical, I am sure alot of Flex developers want it at some point in their life too. Let's take an example:

In user profile page, there is a combobox/dropdownlist for "current employer" which should have an item named "No employer" along side with other real employers like "IBM", "Apple",... We all can imagine that IBM, Apple are from the DB/server side, "No employer" is not, just a label for null-employee. So if "No employer" is selected, the combobox/dropdownlist will return null as selected item.

I googled many times since last year. 100% people suggest to put a dummy item into the dataProvider. I did it and it is kinda good. But I am thinkg about an alternative that I prefer: putting a button (having label = "No employer") in the Combobox/dropdown list, when user clicks on that button then selectedIndex = -1 (i.e selectedItem = null too).

But I am lacking experience and skill to implement such a custom component like that. Please give me some hints or some online ressource to do it.

Thank you very much

Phung D. An
  • 2,402
  • 1
  • 22
  • 23

1 Answers1

1

If you are using Flex 4.5 or above, you can utilize the property "prompt" for the dropdownlist. When no item is selected, the component would display the prompt. So in your case, when the user clicks on the "No employer" button, by setting the selectedIndex=-1, the drop down list should change the text specified in prompt property.

Tianzhen Lin
  • 2,404
  • 1
  • 19
  • 19
  • +1; because I think you're on the right track. But, the prompt was introduced as part of the DropDownList in Flex 4. Prompt is also an element of the MX ComboBox going as far back as at least Flex 3. There is no reason why he is obligated to use Flex 4.5 or higher. The potentialy problem with using the prompt is that "no employer" will not be a valid selection in the drop down. – JeffryHouser Jul 22 '12 at 20:48