Hi,
After a long time I wished to write a post again :)
This time I am writing a simple class but I think it could be very useful to someone. There have been some classes which were copying the data from a datagrid. I decide to write a class which copies only the selected data from the datagrid.
First you will have to set the allowMultipleSelection="true" of the datagrid you want to copy. Then use the following class to copy the selected data from the datagrid.
package com
{
import flash.system.System;
import mx.controls.DataGrid;
public class CopyToCB
{
public static var ccString:String;
public function CopyToCB()
{
}
public static function CopyData(dg:DataGrid):void{
ccString = new String();
for(var i:Number=0;i<dg.columncount;i++){
ccString += dg.columns[i].headerText + "\t";
}
ccString += "\n";
for each(var item:Object in dg.selectedItems){
for(var t:Number=0;t<dg.columncount;t++){
ccString += item[dg.columns[t].dataField] + "\t";
}
ccString += "\n";
}
System.setClipboard(ccString);
}
}
}
Do let me know if it helps you.
Cheers!
-Ravi