创建一种“Ext.data.StoreView”来自多个 Ext.data.Store 对象

发布于 2024-09-28 03:44:22 字数 476 浏览 2 评论 0原文

这是我想要实现的目标:

让 Ext.grid.GridPanel 显示来自多个商店的数据。 放入“数据库术语”,基本上显示了多个商店内容的“视图”。 与使用单元格渲染器相比,这种方法的好处是所有列都可以排序和搜索。

为此,必须定义和配置像 Ext.data.StoreView 这样的对象,以检索并最终转换所有涉及的存储中的数据,并将其呈现给 GridPanel,就像它是单个存储一样。

请注意,即使查看的商店只有一家,这也可能会派上用场。 作为示例,考虑一个具有两个数字字段的商店和一个网格,该网格在各自的列中显示两个字段,第三列显示这两个字段的总和。 您可以使用单元格渲染器轻松地做到这一点,但您会错过对该字段进行排序的机会。 您还可以通过在商店中添加一个“总和”字段并将总和放在那里来实现相同的目的,但这意味着复制值以及在每次更新时保持该字段值同步的所有麻烦。

现在的问题是:有人知道是否存在类似的东西(甚至几乎没有),或者我是否只需要实现它?

谢谢!

Here is what I would like to achieve:

have an Ext.grid.GridPanel show data from multiple stores.
Put in "DB terms", basically showing what would be a "view" of the content of more than one store.
The benefit of this approach, as opposed to using cell-renderers, is that all columns would be sortable and searchable.

For this to work an object like a Ext.data.StoreView would have to be defined and configured to retrieve, and eventually transform, data from all the involved stores and present it to a GridPanel like if it was a single store.

Note that this might come in handy even if the viewed store is just one.
As an example consider a store with two numeric fields and a grid that shows both fields in their respective columns and a third column showing the sum of those two fields.
You can easily do that with a cell renderer, but you miss on the opportunity to sort on that field.
You can also achieve the same by adding a "sum" field to your store and put the sum there, but this would mean replicating values plus all the hassles of keeping that field value in synch at every update.

Now the question: does anybody know if anything (even barely) similar exists or if I just have to implement it ?

Thanks!

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

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

发布评论

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

评论(1

吲‖鸣 2024-10-05 03:44:22

我正在寻求实现类似的东西,但反过来:我希望将同一个商店附加到 2 个网格,但每个网格具有不同的过滤器(在 ExtJs 3.x 中,过滤是在商店级别完成的,而不是在绑定控件上完成) )。

但我希望在一个网格中进行的编辑反映在另一个网格中(如果一个项目与两个过滤器匹配),因此我想编写一个 StoreView 类型类,该类从原始商店复制所有记录(记录实例是特定于商店的)并监听到所有者商店上的事件进行更改,并将任何编辑等应用到原始商店。

其扩展是满足您的需求 - 让这样一个类能够充当多个商店的视图或代理。

如果我还找不到,我计划下周开始写这篇文章 - 如果你想交换笔记/代码,请告诉我......

I'm looking to implement something similar but the other way round: I want the same store attached to 2 grids, but with different filters for each grid (in ExtJs 3.x the filtering is done at the store level, not the bound control).

But I want edits made in one grid to be reflected in the other (if an item matches both filters) so figured I'd write a StoreView type class that copied all the records from the original store (record instances are store specific) and listened to events on the owner Store for changes, and also applied any edits etc to the original store.

An extension of that would be to satisfy your need - have such a class be able to act as a view or proxy onto more than one store.

I'm planning to start writing this next week if I can't find one already - if you want to swap notes/code let me know...

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