thanks but it hasn't done what i want (thanks anyway).

However, I have managed to get success by doing the following code 
in creationComplete of the defined component.


<mx:Component id="myCombo">
 <mx:ComboBox labelField="Text" initialize="startUP()"
     creationComplete="doThis()">
 <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;
 }

 private function doThis():void
 {
   var myListData:DataGridListData = DataGridListData(listData);
   for(var i:int=0;i<this.dataProvider.length;i++)
   {
     if(this.dataProvider[i].Text == data[myListData.dataField])
     {
        index = i;
        break;
     }
   }
   this.selectedIndex = (index == -1) ? 0 : index;
 }
]]>
 </mx:Script>
 </mx:ComboBox>
</mx:Component>


--- In [email protected], "Jim Robson" <[EMAIL PROTECTED]> 
wrote:
>
> Set the editorDataField attribute:
> 
>  
> 
> <mx:DataGridColumn dataField="Text" editorDataField="Text"
> itemEditor="{myCombo}"/>
> 
>  
> 
>   _____  
> 
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of bhaq1972
> Sent: Thursday, June 08, 2006 7:07 AM
> To: [email protected]
> 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. 
<http://www.adobe.com/2006/mxml>
> 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>
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
You can search right from your browser? It's easy and it's free.  See how.
http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to