开发者

Create a sort of "Ext.data.StoreView" from multiple Ext.data.Store objects

开发者 https://www.devze.com 2023-01-20 14:28 出处:网络
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.

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!


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号