I have an AdvancedDataGrid with editable parameter to "true". My problem is that after a successfull drag & drop, the item is being edited and I don't want this to happen.
I tried to create a custom advancedDataGrid with this:
override protected function dragCompleteHandler(event:DragEvent):void{
trace("call dragCompleteHandler");
super.dragCompleteHandler(event);
clearAllSelection();
selectedItem = null;
}
But It doesn't work and I just don't know if I have to stop an event with preventDefault or something else. I also looked into the Adobe AdvancedDataGrid code and it seems that after a dragcomplete event there is nothing dispatched...
How can I stop this annoying edition (or focus) after a drag & drop?
EDIT 27/02/2012
The solution is to listen to DRAG_START and DRAG_COMPLETE events, in the constructor (or init function of the component):
addEventListener(DragEvent.DRAG_START,itemDragStartHandler);
addEventListener(DragEvent.DRAG_COMPLETE,itemDragCompleteHandler);
and :
protected function itemDragStartHandler(event:DragEvent):void
{
editable = "false";
}
protected function itemDragCompleteHandler(event:DragEvent):void
{
editable = "true";
}
Try listening to the itemEditBeginning
event. It is cancelable, so you can use preventDefault()
to stop the editor from showing. You'll probably need to store the items that have been dragged / are being dragged in order to prevent the edit event only when a drag & drop has occurred. I'm not sure in which order the itemEditBeginning
and the drag & drop events are dispatched, so'll need to experiment a little bit. Using trace
is a good way to debug those events...
Another solution I can think of is to set editable
to false
when the drag & drop starts and set it to true
when the drag & drop is complete.