在 Flex3 中将一个数据源用于多个数据网格

发布于 2024-08-23 07:27:54 字数 912 浏览 8 评论 0原文

我想对多个数据网格使用一个数据源(例如数组),这些数据网格附加了不同的filterFunctions并显示不同的列。 首先,我想我使用一个非常直接的方法:

  • 创建数组
  • 为每个 DataGrid 创建一个 ArrayCollection 并将“源”属性设置为数组
  • 创建 DataGrid 并将其 dataProvider 属性设置为其指定的 ArrayCollection

所以现在。每个 ArrayCollection 都可以有自己的 filterFunction、排序状态等,但只需要一个 Array 来存储内存中的所有数据。

现在到了让我完全困惑的地步: 当新项目添加到数组中时,当然不会调度任何事件,我必须在每个 ArrayCollections 上手动调用 itemUpdated。在调试代码以更深入地了解 Flex 时,我试图弄清楚这个神秘的“itemUpdated”方法的作用,特别是正如它在 adobe 文档中指出的那样,如果没有给出“属性”(例如它是空的),一个简单的“refresh()”将会发生。 在整个调试过程中,我没有找到任何对“refresh()”的调用(并且我尽可能深入地了解了整个框架(顺便说一句:代码中有很多有趣的注释:-)))。 我唯一能找到的是 CollectionChangeEvent 在其“item”属性中使用 PropertyChangeEvent 进行调度。这是一种“更新”(而不是我所期望的“添加”)。当尝试手动分派该事件时,它从未起作用(例如数据网格未更新)。 我知道我暂时必须坚持使用 itemUpdated,但随着数据提供者变得越来越大(在两个维度上),性能确实让我担心,我想了解幕后发生的事情。

正如预期的那样,adobe 没有提供任何帮助:-(

非常感谢所有阅读全文的人。 更要感谢那些回答并给我一些轻微暗示的人,让我摆脱困惑并更好地理解(如果可能的话)。

最诚挚的问候,

赫伯特

I want to use one data source (e.g. an Array) for multiple Datagrids that have different filterFunctions attached and show different columns.
First, I thought I use a very straight forward apporach:

  • create the Array
  • create an ArrayCollection for every DataGrid and set the "source" property to the Array
  • create the DataGrids and set their dataProvider property to its designated ArrayCollection

So now. every ArrayCollection can have its own filterFunction, sort state etc. but there needs to be only one Array with all the data in memory.

Now to the point that totally confused me:
As new items are added to the Array, of course no Events are dispatched and I have to call itemUpdated manually on each of the ArrayCollections. While debugging into the code in order to get a deeper understanding for Flex, I tried to figure out, what this misterious "itemUpdated" method does, especially as it notes in the adobe documentation, that, if no "property" is given (e.g. it is null), a simple "refresh()" will occur.
I did not find any calls to "refresh()" in the whole debugging (and I went down the framework whole as deep as possible (btw: lots of funny comments right in the code :-) )).
The only thing I could find was a CollectionChangeEvent getting dispatched with a PropertyChangeEvent in its "item" property. Which was of the kind "UPDATE" (and not, as I would expect "ADD"). When trying to dispatch that event manually, it never worked (e.g. the datagrid did not update).
I know I have to stick with itemUpdated for the moment, but as the dataprovider can get big (in both dimensions), performance does concern me and I wnat to understand what is going on under the hood.

And as expected, no help from adobe :-(

So a big thanks for everyone who read this whole text.
And an even bigger THANKS to anyone who answers and gives me the slightes hint in how I can get out of the confusion and understand (if thats possible at all) Fles a little better.

finest of all regards,

herbert

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

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

发布评论

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

评论(1

春庭雪 2024-08-30 07:27:54

您必须为每个 dataProvider 调用 ArrayCollection.refresh() 才能获取 dataGrid 以显示对源数组的新更改。

You have to call ArrayCollection.refresh() for each of your dataProviders to get the dataGrids to show the new changes to the source array.

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