For a renderer of that complexity, I would not use the DGs native editable
process, but would handle the dataProvider item updates within the renderer
itself.

 

Tracy

 

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of Gal Afik
Sent: Saturday, March 07, 2009 10:42 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] drag&drop inside itemEditor in dataGrid...a tricky
question

 

Hello all

I'd really appreciate your help on this.
I have a itemEditor in my datagrid (see attached code).. this is a drag&drop
text input... I drag words inside and it concatenates them to a comma
separated string...
I've embedded it in the grid like that:
<mx:DataGridColumn headerText="Prevent ctx" dataField="@prevent_ctxs"
rendererIsEditor="true" width="200"
itemRenderer="CtxTI" editable="true"/>

The problem is that the grid does not sense the itemBegin/itemEnd events
when I drag things inside..
and therefore does not activate the editor/automatically "pull" the data of
the itemEditor and puts it into the grid..

Can anyone figure a way to correct/around this?

Thanks in advance
Afik Gal 

<============== CtxTI.mxml ===>
<?xml version="1.0" encoding="utf-8"?>
<mx:TextInput xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml>
com/2006/mxml"
dragDrop="dragDrop(event)" dragEnter="dragAccept(event)">
<mx:Script>
<![CDATA[

import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.controls.listClasses.ListData;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;

override public function set data(value:Object):void
{
super.data=value;
var attrib:String=
DataGridListData(listData).dataField.substr(1,-1+DataGridListData(listData).
dataField.length);
var input:String;
if (value) input=XML(value).attribute(attrib)[0].toString(); 
if (input!="") this.text=input;
}


private function dragAccept(event:DragEvent):void
{
var dropTarget:TextInput = event.currentTarget as TextInput;
DragManager.acceptDragDrop(dropTarget);
} 
private function dragDrop(event:DragEvent):void
{ 
if (!event.dragSource.hasFormat("treeItems")) return;
var arr:Array = event.dragSource.dataForFormat("treeItems") as Array;
var str:String = XML(arr[0])....@label.tostring();
if ((this.text.substr(-1)!=",") && (this.text.length>0)) this.text+=",";
this.text+=str+",";
}
]]>
</mx:Script>
</mx:TextInput>



Reply via email to