Flex:如何实时更改绑定到数据网格的 ArrayCollection?
我有一个绑定到可编辑 DataGrid 的 ArrayCollection,另一个组件需要知道 ArrayCollection 何时更改(由于 DataGrid 中的更改),以便它也可以更新自身,监听 ArrayCollection 的 COLLECTION_CHANGE 事件也是如此。
问题是,当正在编辑的行失去焦点时,DataGrid 仅更新 ArrayCollection。这对我的应用程序不利,因为用户可以编辑行上的列,并且长时间不单击表上的其他位置(导致该行失去焦点),因此更改不会传播到表的其他部分该应用程序。
如何使数据网格在每次文本输入上出现 keyup 事件时(而不是每次行失去焦点时)通知 ArrayCollection 发生更改?
干杯,
克里斯
I have an ArrayCollection bound to an editable DataGrid, another component needs to know when the ArrayCollection changes (as a result of changes in the DataGrid) so it can also update itself, so is listening to the COLLECTION_CHANGE event of the ArrayCollection.
The problem is that the DataGrid only updates the ArrayCollection when the row being edited losses focus. This is not good for my app as a user could edit a column on a row and not click elsewhere on the table for a long time (causing the row to lose fucus), therefore the changes won't have propagated to the other parts of the application.
How can I make the data grid inform the ArrayCollection of a change every time there is a keyup event on a text input instead of every time a row looses focus?
Cheers,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会将处理程序添加到用于编辑值的组件中,而不是添加到 ArrayCollection 中。示例:
然后使用它来编辑值:
这是更改(和关闭)事件的处理程序:
_currentlyEditedRowIndex
通过将其添加到网格来设置:I would add the handler to the component used to edit the value instead of to the ArrayCollection. Example:
Then this is used to edit the value:
And this is the handler for the change (and close) event:
_currentlyEditedRowIndex
is set by adding this to the grid:谢谢加布里埃尔,你让我走上了正确的道路。我将在这里发布我的最终解决方案,以防其他人将来需要做同样的事情。
现在,每当输入中的文本发生更改时,用作数据提供程序的 ArrayCollection 也会更新,因此其他组件会侦听 COLLECTION_CHANGE 事件。
Thanks Gabriel you put me on the right path. I will post here my final solution in case anyone else needs to do the same thing in the future.
Now whenever the text is changed in the input the ArrayCollection being used as the data provider is also updated, so other components listen for COLLECTION_CHANGE events.