Link to home
Start Free TrialLog in
Avatar of hallikpapa
hallikpapa

asked on

Best way to disable combobox?

I am trying to globally enable/disable form fields based on a boolean var I am setting dynamically per record.

This code is not working for my comboBox, I am still able to change the values even though I editMode = false.

Neither one of these fields should be editable because the editMode = false (both in default and in the value I am passing in), but I activate the date picker & drop down menu.

What am I doing wrong?

I have tried enabled=, but it makes the whole combobox background a darkgrey color, and I don't want to color to change, just unclickable.

If I must use enabled for both combobox and datepicker, how do I change the background color to it? There doesn't seem to be an attribute I can find for that.



[Bindable] public var editMode = false;
..
..
..
<mx:FormItem direction="horizontal" label="District" required="true">
	<mx:ComboBox id="districts" labelField="name" dataProvider="{districtCollection}"
		open="{editMode}"
                editable="{editMode}"
		change="onDistrictSelected(event)"/>
</mx:FormItem>
 
<mx:FormItem required="true" label="Date:">
	<mx:DateField id="date" selectedDate="{report.startDate}" editable="{editMode}"/>
</mx:FormItem>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jones911
Jones911

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hallikpapa
hallikpapa

ASKER

Right, that's one thing I tried, except I mentioned that it makes everything dark grey & unreadable. How can I set it where it's just an off-white, or white, but still disabled?
If you make a custom skip for disabledIcon you can make it look how you want, but you will have to draw it up as a PNG.  Perhaps there is a style to change it.  I'll look more later.
Thanks. I thought I could make it work like this:
http://blog.flexexamples.com/2008/07/19/setting-the-label-color-on-a-disabled-combobox-control-in-flex/

My code is almost the same, except I am not using a color picker. I just explicitly set the color value to #999999, but it isn't coming out as it should.

I can't tell if the text color is changing, because the background color is so dark and I can't figure out how to make that not change between enable/disable.

But they seem to accomplish this in that demo....
Avatar of zzynx
>> My code is almost the same, except...
Please show us your code
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The combobox is dark grey, text is unreadable. Not like on the URL i posted above. It looks like the text color is the only thing changing when disabled, whereas the background on my combo box goes dark grey. I checked the main.css, and there is no entry for FormItem.



<mx:FormItem direction="horizontal" label="District" required="true">
						<mx:ComboBox id="districts" labelField="name" dataProvider="{districtCollection}"
							change="onDistrictSelected(event)"
							enabled="{editMode}"
							disabledColor="#999999"
							disabledIconColor="#FFFFFF"
							/>
					</mx:FormItem>

Open in new window

The problem was I was disabling the combobox, and not the form item. Thanks.