0

In Ext JS there is a chained store that allows us to sit on top of an existing store and perform grouping, filtering and sorting of the underlying store without affecting the actual data in the store.

Is there some way we could do something similar but provide a function that would aggregate the data in the store, which could then be used by another component to view the aggregation?

For example, lets say I have a store that has a collection of objects with a date and a value. I have a grid that shows every item in that store. But I want to have another component that shows the data aggregated by day. So I want to take that raw data and collect all items that have the same date and sum the values.

I know that grids have grouping summary options, but I don't want all of the data to appear in the grid alongside the summary, just the grouping summary.

One component looks like: |Date |Value| |1/1/18|1 | |1/1/18|5 | |2/1/18|1 | ...

The other: |1/1/18|2/1/18|etc.| |6 |1 |etc.|

Vy Do
  • 46,709
  • 59
  • 215
  • 313
DaveJohnston
  • 10,031
  • 10
  • 54
  • 83
  • `But I want to have another component that shows the data aggregated by day` can you explain about your second component which xtype you have used ? – Narendra Jadhav Jun 09 '18 at 16:44
  • Both components are `Ext.grid.Panel`s. One is a simple vertical grid with two columns date and value. The other is a horizontal grid where the header is a week's worth of days and the aggregated values should be displayed in the column – DaveJohnston Jun 09 '18 at 16:51
  • As far as I know, you want to implement that by hand. The store aggregate functions may come handy, but you may have to implement the actual aggregation logic yourself. – Alexander Jun 09 '18 at 21:06
  • Ok, so if I have two grids each needs to be backed by a store, so how would I manually take the data in store 1 and convert it to the required data for store 2? Preferably in such a way that if I edit the data in store 1 the data in store 2 is also updated. – DaveJohnston Jun 09 '18 at 22:25
  • You can do like this http://jsfiddle.net/R3p4c/2/ ( https://stackoverflow.com/a/11199847/3728901 ) – Vy Do Jun 10 '18 at 12:38
  • @DoNhuVy this does not help me, the issue is related to use of ExtJS grid panel with a different view on an existing store. I can easily perform the aggregation, I just want to know how I can hook up the two stores so that ExtJS handles the synchronisation of the components. – DaveJohnston Jun 10 '18 at 18:11

0 Answers0