简体   繁体   中英

How to Make Combobox and DateField as non editable dynamically in flex

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 label="District" required="true">


<mx:ComboBox id="districts" labelField="name" dataProvider="{districtCollection}"
            editable="{editMode}"
    click="onDistrictSelected(event)"/> </mx:FormItem> <mx:FormItem label= "Date><mx:DateField id="date" selectedDate="{report.startDate}" editable="{editMode}"/>

Thanks in advance...

How about the mouseEnabled property? That should make the controls not editable and shouldn't change their background color.

The flex documentation states that editable only prevents the user from typing in values into the combobox, it doesn't stop them from using the list of the combobox.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/ComboBase.html#editable

<mx:FormItem label="District" required="true" enabled="{editMode}" disabledOverlayAlpha="0">
    <mx:ComboBox id="districts" labelField="name" dataProvider="{districtCollection}"
          click="onDistrictSelected(event)"/> 
</mx:FormItem> 
<mx:FormItem label= "Date" enabled="{editMode}" disabledOverlayAlpha="0">
     <mx:DateField id="date" selectedDate="{report.startDate}"/>
</mx:FormItem> 

Try above code... this will sole your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM