Flex 阻止数据网格在拖拽后进行编辑降低

发布于 2025-01-08 16:20:08 字数 1057 浏览 0 评论 0原文

我有一个 AdvancedDataGrid,其可编辑参数为“true”。我的问题是,在成功拖放之后, drop,该项目正在编辑中,我不希望发生这种情况。

我尝试用这个创建一个自定义的advancedDataGrid:

override protected function dragCompleteHandler(event:DragEvent):void{
            trace("call dragCompleteHandler");
            super.dragCompleteHandler(event);
            clearAllSelection();
            selectedItem = null;
        }

但是它不起作用,我只是不知道是否必须使用preventDefault或其他东西来停止事件。我还研究了 Adob​​e 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烂柯人 2025-01-15 16:20:08

尝试监听 itemEditBeginning 事件。它是可以取消的,因此您可以使用 preventDefault() 来阻止编辑器显示。您可能需要存储已拖动/正在拖动的项目,以防止仅在拖动和拖动时才发生编辑事件。发生了掉落。我不确定 itemEditBeginning 和拖拽的顺序。 drop 事件已调度,因此需要进行一些实验。使用 trace 是调试这些事件的好方法...

我能想到的另一个解决方案是在拖动时将 editable 设置为 false ;当拖动开始时,将其设置为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文