Flex 3:Datagrid 作为项目编辑器获取“itemEditEnd”过早地

发布于 2024-11-02 05:16:48 字数 728 浏览 5 评论 0原文

我的应用程序有一个带有自定义项目渲染器的树,它根据叶子上的数据类型使用不同的组件作为编辑器。在一种情况下,我尝试使用数据网格,以便用户可以选择满足其需求的行(需要显示几列),即。在概念上与 ComboBox 类似。

为此,我分配了一个函数作为“itemEditBegin”(针对树)的处理程序,在其中动态创建数据网格,然后使用弹出窗口管理器将其显示为(模式)弹出窗口。到目前为止,一切都很好。

但是,如果您单击任意位置(例如数据网格中的向下滚动按钮),弹出窗口就会消失,因为 itemEditEnd 事件被触发 - 为什么?!

在另一种情况下,我有一个 DateField 设置作为编辑器,用户可以单击该图标来调出 DateChooser,滚动浏览月份等。我查看了这背后的代码,它使用了一个弹出窗口,似乎与我的代码完全相同!

以下是“itemEditBegin”代码:

dataGrid = new DataGrid();
dataGrid.dataProvider = mddTable.dataCollection;
dataGrid.editable = false;
PopUpManager.addPopUp(dataGrid, this, true);

其中“this”是树渲染器用于行的组件。一旦单击数据网格内的任何内容(例如,行、向下滚动按钮、列分隔符等),就会调用树组件的“itemEditEnd”处理程序。

有人有什么想法吗?

谢谢,

迈克。

My application has a tree with a custom item renderer, which depending on the type of data at a leaf uses different components as editors. In one case I am trying to use a datagrid so that the user can choose a row that meets his needs (several columns need to be displayed), ie. similar in concept to a ComboBox.

To do this I have a function assigned to be the handler for 'itemEditBegin' (for the tree) in which I'm dynamically creating the datagrid, and then using the popup manager to display it as a (modal) popup. So far so good.

However, if you click anywhere (eg. scroll down button in the datagrid) the popup disappears because the itemEditEnd event is fired - why ?!

In another scenario, I have a DateField setup as the editor, and the user can click on the icon to bring up a DateChooser, scroll through the months, etc. I looked at the code behind this, and it is using a popup, seemingly in exactly the same way as my code !

Here is the 'itemEditBegin' code:

dataGrid = new DataGrid();
dataGrid.dataProvider = mddTable.dataCollection;
dataGrid.editable = false;
PopUpManager.addPopUp(dataGrid, this, true);

where 'this' is the component used by the tree renderer for a row. It is the tree component's 'itemEditEnd' handler that is being called as soon as anything inside the datagrid is clicked (eg. a row, scroll down button, column divider etc).

Any ideas anyone ?

Thanks,

Mike.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

红墙和绿瓦 2024-11-09 05:16:48

我想我必须看到代码,或者在实践中才能完全理解。听起来当您使用 DataGrid 作为项目编辑器时,各个 DataGrid 列是可编辑的。这是正确的吗?

当您将焦点移出 DataGrid 中的 itemEditor 时,它将触发 itemEditEnd 事件。你的树一定对此做出了某种反应。尝试停止 DataGrid 类中的事件传播。从概念上讲是这样的:

<mx:DataGrid>
 <mx:Script>
   public function oItemEditEnd(event:DataGridEvent):void{
     event.stopPropogation();
   }
 </mx:Script>
 <mx:columns>
   <mx:DataGridColumn itemEditEnd="onItemEditEnd(event)">
   <mx:DataGridColumn itemEditEnd="onItemEditEnd(event)">
 </mx:columns>
</mx:DataGrid>

如果您这样做,您将必须做一些事情来确定用户何时完成编辑并手动关闭 itemEditor。

有关 stopPropogation( )。。另请查看 stopImmediatePropogation( )。我不确定您需要哪一个,因为这取决于您的代码的结构。

I guess I'd have to see code, or this working in practice to fully understand. It sounds like the individual DataGrid Columns are editable when you're using the DataGrid as an itemEditor. Is that correct?

When you focus out of an itemEditor in the DataGrid, it will fire the itemEditEnd event. Your tree must be reacting to this somehow. Try to stop the event propogation in your DataGrid class. Conceptually something like this:

<mx:DataGrid>
 <mx:Script>
   public function oItemEditEnd(event:DataGridEvent):void{
     event.stopPropogation();
   }
 </mx:Script>
 <mx:columns>
   <mx:DataGridColumn itemEditEnd="onItemEditEnd(event)">
   <mx:DataGridColumn itemEditEnd="onItemEditEnd(event)">
 </mx:columns>
</mx:DataGrid>

If you do this, you're going to have to do something to figure out when the user is done editing and close the itemEditor manually.

More info on stopPropogation().. Also check out stopImmediatePropogation(). I'm not sure which one you'll need as it depends how your code is structured.

∞梦里开花 2024-11-09 05:16:48

最终我找到了一个解决方案,更多地解决了问题。只需在行中添加:

dataGrid.owner = this;

解决了过早的 itemEditEnd 事件问题。但是,现在我遇到了相反的问题,在我单击树的另一行之前,itemEditEnd 事件不会被触发!

我在数据网格上有一个“项目单击”侦听器,当单击其中一个值时,它会破坏数据网格,但仅执行此操作不会导致基础树行的 itemEditEnd 事件触发。我在文档中读到,组件失去焦点会导致它,所以我调度了自己的“FocusEvent.FOCUS_OUT”事件 - 没有好处。

如果我手动将焦点更改为基础树,则 itemEditEnd 事件会触发并且一切都很好,但必须将树的引用传递给树渲染器的行对象似乎有点笨拙!

有人有更好的想法吗?

谢谢,

迈克

Eventually I found a solution that moreless fixes the problem. Simply adding in the line:

dataGrid.owner = this;

solved the premature itemEditEnd event problem. However, now I have the opposite problem, where the itemEditEnd event doesn't get fired until I click on another row of the tree !

I have an 'item clicked' listener on the datagrid which destroys the datagrid when one of the values is clicked, but just doing this doesn't cause the itemEditEnd event of the underlying tree row to fire. I read in the docs that the component losing focus causes it, so I dispatched my own 'FocusEvent.FOCUS_OUT' event - no good.

If I manually change the focus to the underlying tree, the itemEditEnd event does fire and all is good, but it seems a bit clunky to have to pass a reference of the tree to the tree renderer's row object !

Anyone have any better ideas ?

Thanks,

Mike

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