Set the editorDataField attribute:

 

<mx:DataGridColumn dataField="Text" editorDataField="Text" itemEditor="{myCombo}"/>

 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of bhaq1972
Sent: Thursday, June 08, 2006 7:07 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Flex2B3 - set the combobox selectedItem within an inline script

 

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>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to