Hello Experts,
I have following piece of code from main mxml and below that I have
component code for Combobox. Please let me know what is wrong in my
code. It wipe the value once I select values from combo box. I am
using label function to decode values as Yes/No when populating Data
Grid from the database. Also I will appreciate if I get a standard way
to display Yes/No list to display and store values(Y/N) in database.
My code is based on various examples given on this topic. Sorry if I
have made the Code-cocktail.
Thanks a lot.
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>
---------------------------------Item Render yesNoComboBox ----------
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.controls.listClasses.IDropInListItemRenderer,mx.managers.IFocusManagerComponent">
<mx:Script>
<![CDATA[
import flash.events.Event;
import mx.controls.DataGrid;
private var _listData:DataGridListData;
// Define a property for returning the new value to the
cell.
[Bindable]
public var value:Object ;
// Implement the drawFocus() method for the VBox.
override public function drawFocus(draw:Boolean):void {
cbo.setFocus();
}
override public function get data():Object {
return super.data;
}
/* override public function set data(value:Object):void {
cbo.data=value[_listData.dataField];
} */
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
// set itemRenderer’s state based on
data value
cbo.selectedItem = value;
}
}
public function get listData():BaseListData
{
return _listData;
}
public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
}
public function changeHandler(event:Event):void
{
trace(String(cbo.selectedItem))
data.selected=String(cbo.selectedItem);
IList(DataGrid(owner).dataProvider).itemUpdated(cbo.selectedItem);
}
]]>
</mx:Script>
<mx:Binding destination="value" source="cbo.value"/>
<mx:ComboBox id="cbo" editable="true" width="100%"
dataChange="changeHandler(event)"
creationComplete="cbo.selectedItem = data.selected" >
<mx:dataProvider>
<mx:String>Yes</mx:String>
<mx:String>No</mx:String>
</mx:dataProvider>
</mx:ComboBox>
</mx:VBox>
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.