In general terms, build an ArrayCollection from the data you want to pass, and assign that ArrayCollection to the dataprovider property of the second grid.

 

Tracy

 


From: [email protected] [mailto:[email protected]] On Behalf Of s_hernandez01
Sent: Wednesday, August 09, 2006 9:43 AM
To: [email protected]
Subject: [flexcoders] passing data to a datagrid

 

Hey Flexers,

I am trying to send specific data from a datagrid to another datagrid
and am having trouble with my actionscript. I can manage to send data
if the index is selected, but I only want to send certain data to the
other datagrid. Can anyone help? Here is what I have so far...

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns="*" creationComplete="init()">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.effects.*;
import mx.core.*;

public function init():void{
srv.send();
addEventListener("send",doSendEvent);
}

public function doSendEvent(event:Event):void{
addToGrid(event.target.data);
}

public function addToGrid(product:Object):void{
destGrid.addItem({cat: product.cat, upc: product.upc, description:
product.description});
}
]]>
</mx:Script>

<mx:HTTPService id="srv" url="">xml" useProxy="false"
result="(srv.lastResult.catalog.product)"/>

<mx:HBox x="0" y="0" width="100%" height="100%"
verticalAlign="middle" horizontalAlign="center">

<mx:DataGrid dataProvider="{srv.lastResult.catalog.product}"
id="srcGrid" itemClick="init()">
<mx:columns>
<mx:DataGridColumn headerText="UPC" dataField="cat" width="60"/>
<mx:DataGridColumn headerText="CAT NO." dataField="upc" width="60"/>
<mx:DataGridColumn headerText="DESCRIPTION" dataField="description"
width="300"/>
<mx:DataGridColumn headerText="WEIGHT" dataField="wgt" width="60"/>
<mx:DataGridColumn headerText="BALANCE" dataField="balance" width="60"/>
</mx:columns>
</mx:DataGrid>

<DestGrid id="destGrid" width="50%" height="20%"/>

</mx:HBox>
</mx:Application>

<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml"
dataProvider="{myDP}">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.effects.*;
import mx.core.*;

[Bindable]
public var myDP:ArrayCollection = new ArrayCollection();

public function addItem(item:Object):void{
myDP.addItem(item);
}
]]>
</mx:Script>
<mx:columns>
<mx:DataGridColumn headerText="UPC" dataField="cat" width="60"/>
<mx:DataGridColumn headerText="CAT NO." dataField="upc" width="60"/>
<mx:DataGridColumn headerText="DESCRIPTION" dataField="description"
width="300"/>
</mx:columns>
</mx:DataGrid>

__._,_.___

--
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