Hello,
I have following piece of code from main mxml and below that I have
component code for Combobox. I am using label function to decode values as
Yes/No when populating Data Grid from the database. It wipe the value from the
cell once I click on the combobox and don't select values from it. I used
prompt in combobox which works to avoid blank but it change the values to
prompt.
I tried many examples but didn't work for me. Please help. Also I want to use
Item Renderer instead if Item Editor.
Thanks
Arshad
main.mxml
---------------------
[Bindable] private var queryData:ArrayCollection = new ArrayCollection();
------
------
<mx:DataGrid id="dgGrid" width="644" dataProvider="{queryData}" height="270"
editable="true" >
------
-----
<mx:DataGridColumn width="175" textAlign="center"
headerText="Tax" sortable="false" dataField="tax"
labelFunction="taxLabel"
editable="true" editorDataField="value"
itemEditor="yesNoComboBox">
</mx:DataGridColumn>
---------------------------------yesNoComboBox ----------
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.controls.listClasses.IDropInListItemRenderer,mx.managers.IFocusManagerComponent">
<mx:Script>
<![CDATA[
import mx.controls.listClasses.ListData;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import mx.controls.dataGridClasses.DataGridItemRenderer
import mx.events.FlexEvent;
private var _listData:DataGridListData;
[Bindable]
public var cmbValue:Object;
override public function get data():Object {
return super.data;
}
override public function set data(value:Object):void {
cbo.data=value[_listData.dataField];
cbo.selectedItem= value[_listData.dataField];
trace("---->"+cmbValue)
}
public function get listData():BaseListData
{
return _listData;
}
public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
}
]]>
</mx:Script>
<mx:Binding destination="cmbValue" source="cbo.value"/>
<mx:ComboBox id="cbo" editable="true" width="100%" >
<mx:dataProvider>
<mx:String>Yes</mx:String>
<mx:String>No</mx:String>
</mx:dataProvider>
</mx:ComboBox>
</mx:VBox>