Flex 阻止数据网格在拖拽后进行编辑降低
我有一个 AdvancedDataGrid,其可编辑参数为“true”。我的问题是,在成功拖放之后, drop,该项目正在编辑中,我不希望发生这种情况。
我尝试用这个创建一个自定义的advancedDataGrid:
override protected function dragCompleteHandler(event:DragEvent):void{
trace("call dragCompleteHandler");
super.dragCompleteHandler(event);
clearAllSelection();
selectedItem = null;
}
但是它不起作用,我只是不知道是否必须使用preventDefault或其他东西来停止事件。我还研究了 Adobe AdvancedDataGrid 代码,似乎在 DragComplete 事件之后没有任何内容调度...
我怎样才能在拖拽完成后停止这个烦人的版本(或焦点)?降低?
编辑 27/02/2012
解决方案是在构造函数(或组件的 init 函数)中监听 DRAG_START 和 DRAG_COMPLETE 事件:
addEventListener(DragEvent.DRAG_START,itemDragStartHandler);
addEventListener(DragEvent.DRAG_COMPLETE,itemDragCompleteHandler);
并且:
protected function itemDragStartHandler(event:DragEvent):void
{
editable = "false";
}
protected function itemDragCompleteHandler(event:DragEvent):void
{
editable = "true";
}
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";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试监听
itemEditBeginning
事件。它是可以取消的,因此您可以使用preventDefault()
来阻止编辑器显示。您可能需要存储已拖动/正在拖动的项目,以防止仅在拖动和拖动时才发生编辑事件。发生了掉落。我不确定itemEditBeginning
和拖拽的顺序。 drop 事件已调度,因此需要进行一些实验。使用trace
是调试这些事件的好方法...我能想到的另一个解决方案是在拖动时将
editable
设置为false
;当拖动开始时,将其设置为true
。掉落完成。Try listening to the
itemEditBeginning
event. It is cancelable, so you can usepreventDefault()
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 theitemEditBeginning
and the drag & drop events are dispatched, so'll need to experiment a little bit. Usingtrace
is a good way to debug those events...Another solution I can think of is to set
editable
tofalse
when the drag & drop starts and set it totrue
when the drag & drop is complete.