Hi Karthik,
I don't have any link for that. I just wrote a code and it was working
fine. Below are the snippets for Datagrid, dragRenderer and
dropRenderer.
Let me know if you find them helpful.
<mx:DataGrid dataProvider="{ac}" editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="ename"
itemRenderer="com.DragRenderer"/>
<mx:DataGridColumn dataField="sal"
itemRenderer="com.DropTargetRenderer"/>
</mx:columns>
</mx:DataGrid>
//DragRenderer
public function DragRenderer()
{
super();
this.setStyle("fontWeight","bold");
this.setStyle("textAlign","left");
this.addEventListener(MouseEvent.MOUSE_MOVE,handleDrag);
}
override public function set data(value:Object):void{
super.data = value;
this.text = this.data[(listData as
DataGridListData).dataField];
//this.addEventListener(MouseEvent.CLICK,clickHandler);
}
/* private function clickHandler(e:MouseEvent):void{
}
*/
private function handleDrag(e:MouseEvent):void{
var obj:String = this.text;
var dragInitiator:Text = e.currentTarget as Text;
var dragSource:DragSource = new DragSource();
dragSource.addData(obj,'value');
var dragProxy:Image = new Image();
dragProxy.source = "admin2.gif";
DragManager.doDrag(dragInitiator,dragSource,e,dragProxy);
}
//DropTargetRenderer
public function DropTargetRenderer()
{
super();
this.addEventListener(DragEvent.DRAG_ENTER,dragEnterHandler);
this.addEventListener(DragEvent.DRAG_EXIT,dragExitHandler);
this.addEventListener(DragEvent.DRAG_DROP,dragDropHandler);
}
private function dragEnterHandler(e:DragEvent):void{
var dropTarget:Text = e.currentTarget as Text;
if(e.dragSource.hasFormat('value')){
DragManager.acceptDragDrop(dropTarget);
}
}
private function dragExitHandler(e:DragEvent):void{
var dropTarget:Text = e.currentTarget as Text;
}
private function dragDropHandler(e:DragEvent):void{
var value:String = e.dragSource.dataForFormat('value')
as String;
(e.currentTarget as Text).text += value;
}
-Ravi
On Apr 20, 12:10 pm, Karthik K <[email protected]> wrote:
> Hi Ravi
>
> thanks for your response i am searching for any samples but not able to find
>
> is there any samples or link which will help me
>
> Thanks
>
> --
> Karthik.k
> Mobile - +91-9894991640
>
> On 4/20/09, Ravi Mishra <[email protected]> wrote:
>
>
>
> > Hi Karthik,
>
> > Yes we can drag the data from one cell to another cell of a datagrid.
> > And to achieve that you will have to use itemrenderers. You will have
> > to write a logic for drag and drop in those itemrendrers.
>
> > HTH,
>
> > -Ravi
>
> > On Apr 20, 10:49 am, Karthik K <[email protected]> wrote:
> > > hi guys
>
> > > i need to know one thing
>
> > > can we drag data from one cell to another cell in same datagrid
>
> > > can we do this in advanced datagrid or in normal datagrid
>
> > > please help
>
> > > Thanks
>
> > > --
> > > Karthik.k
> > > Mobile - +91-9894991640
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---