thanks Sangeetha Kalyani.... 
Let me try this. but nt sure wheather the IViewCUrsor is supported in flex
3.4 _ flash player 9?? 
But its a great help.. thanks!!




Sangeeta Kalyani wrote:
> 
> Hi Anjana,
> 
> You can iterate over the datagrid in Flex using below code and send
> the data to the server.
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="vertical" creationComplete="init()">
>       <mx:Script>
>               <![CDATA[
>                       import mx.controls.Alert;
>                       import mx.rpc.events.FaultEvent;
>                       import mx.rpc.events.ResultEvent;
>                       import mx.collections.IViewCursor;
>                       import mx.collections.ArrayCollection;
> 
>                       [Bindable]
>                       private var dp:ArrayCollection;
> 
>                       private var csvStr:String = "";
> 
>                       private function init():void {
>                               dp = new 
> ArrayCollection([{name:"Sangeeta",email:"[email protected]"},
> {name:"Kalyani",email:"[email protected]"}]);
>                               dg.dataProvider = dp;
>                       }
> 
> 
>                       private function export():void {
>                               var dpObj:Object=dg.dataProvider;
>                               var cursor:IViewCursor=dpObj.createCursor();
>                               while( !cursor.afterLast )
>                               {
>                                 // Access each column field like: 
> cursor.current.MyFieldName
>                                 csvStr += cursor.current.name 
> +","+cursor.current.email + "\n";
> 
>                                 // Obviously don't forget to move to next row:
>                                 cursor.moveNext();
>                               }
>                               ro.createCSV(csvStr);
>                       }
> 
>                       private function resultHandler(event:ResultEvent):void {
>                               //Create CSV file at server (Can use java)      
>                 }
> 
>                       private function faultHandler(event:FaultEvent):void {
>                               Alert.show(event.fault.toString());
>                       }
> 
>               ]]>
>       </mx:Script>
> 
>       <mx:RemoteObject id="ro" destination="roDest"
> result="resultHandler(event)" fault="faultHandler(event)">
> 
>       </mx:RemoteObject>
> 
>       <mx:DataGrid id="dg">
>               <mx:columns>
>                       <mx:DataGridColumn dataField="name" headerText="Name">
> 
>                       </mx:DataGridColumn>
>                       <mx:DataGridColumn dataField="email" headerText="Email">
> 
>                       </mx:DataGridColumn>
>               </mx:columns>
> 
> 
>       </mx:DataGrid>
> 
>       <mx:Button label="Export To CSV" click="export()">
> 
>       </mx:Button>
> 
> </mx:Application>
> 
> Thanks,
> Sangeeta Kayani
> 
> On May 6, 5:20 pm, "anjana.sp" <[email protected]> wrote:
>> Hi ,
>>
>> I want to download the datagrid content from the flex UI as csv file at
>> client end.  How can i do this ?
>> Also, how do i create a file at flex end ? How can i pass the Datagrid
>> data
>> to the server end from Flex ?
>>
>> Could any one throw light on how do i do this ?It would be great if some
>> one
>> can suggest me the solution asap.
>>
>> Note :1) I am using Flex for UI.
>>          2) I can use flash 9 only.
>> --
>> View this message in
>> context:http://old.nabble.com/save-Datagrid-data-into-csv-file-at-client-end-...
>> Sent from the Flex India mailing list archive at Nabble.com.
>>
>> --
>> 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
>> athttp://groups.google.com/group/flex_india?hl=en.
> 
> -- 
> 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.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/save-Datagrid-data-into-csv-file-at-client-end-tp28472853p28489102.html
Sent from the Flex India mailing list archive at Nabble.com.

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

Reply via email to