I've got a Combobox component declared as an
itemEditor in a
datagrid. during its initialize i set its dataprovider.
i then want to set its selecteditem or selectedIndex to be the same
as datagrids dataprovider
any ideas ?
code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
>
<mx:Script>
<![CDATA[
[Bindable]
public var dp:Array = [{ Artist:'Pavement',
Album:'Slanted and Enchanted', Text:'two'},
{ Artist:'Beatles',
Album:'The Best Of', Text:'four' },
{ Artist:'MrT',
Album:'Gold Chains', Text:'five' },
{
Artist:'Hasselhoff', Album:'Kit', Text:'two' }];
]]>
</mx:Script>
<mx:Component id="myCombo">
<mx:ComboBox labelField="Text" initialize="startUP
()">
<mx:Script>
<![CDATA[
public var dp2:Array = [{Text:'one',
Code:'1'}, {Text:'two', Code:'2'}, {Text:'three', Code:'3'},
{Text:'four', Code:'4'}, {Text:'five', Code:'5'}];
private function startUP():void
{
//set the dataprovider
this.dataProvider = dp2;
//set the
selectedindex/selectedItem here
}
]]>
</mx:Script>
</mx:ComboBox>
</mx:Component>
<mx:Text color="yellow" width="70%" text="how do i
set the
combo itemEditor selectedItem to be the same as the dg col
value..within the inline component script"/>
<mx:DataGrid id="dg" dataProvider="{dp}"
width="50%"
editable="true">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="Artist"
headerText="Artist" />
<mx:DataGridColumn dataField="Album"
headerText="Album" />
<mx:DataGridColumn dataField="Text"
itemEditor="{myCombo}"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>