tags:

views:

3158

answers:

2

I want to create a combobox in flex which will take three values, Available, Unavailable, and Busy. The constraint is, I should not allow user to go directly from Unavailable to Busy. So when a User is selected Unavailable, I should keep the Busy item disabled (unselectable), but a user will be able to go directly from Available to Busy. I chouldn't find a straight forward way to disable an item in combobox in Flex. How can I do that?

+1  A: 

Have you considered using radio buttons rather than a combo box? It's clear how to do this for radio buttons, for one thing. Also, it can often be friendlier to present the available options without requiring a click to reveal them. (Especially if, as in this case, you are adding the possibility that an option is "available, but not possible for you right now for some reason not shown in this combo-box item").

If you really want a combo-box, you can use the click event to display it in a non-standard fashion by probably changing its style; and then, if clicked anyway, Then, in the selected event, reject the choice (hopefully with an indication of why),

Or, if you want to simply remove it from the list, you can have the click listener event repopulate the source list each time, based on conditions. But that might be confusing to the user, too.

le dorfier
Thanks, your suggestion really helped.
Mozammel
I'm going with the radio button implementation.
Mozammel
A: 

You can also have a look at

www.stoimen.com/blog/2009/03/05/flex-3-combobox-disabled-options/

which references

wmcai.blog.163.com/blog/static/4802420088945053961/

(note for NoScript users you must have 163.com and 126.com at least temporarily allowed to be able to properly see this page)

it works very well even though I added the code for being able to properly handle keyboard events in the dropdown list

Full self working example available at

http://olivierbourdon.homedns.org/OpenSource/combos.zip

Thanks again for the good work

Olivier Bourdon