View Full Version : Why does sorting a grid also sort its store?

22 Sep 2009, 1:55 PM
And is there a workaround other than manually duplicating the store? I noticed this when sorting my grid resulted in a pie chart inverting itself, both of which share a single store.

22 Sep 2009, 11:27 PM

The Store IS the model. The Grid is just the View of it. This is such an important concept, I can't see how it could pass you by.

23 Sep 2009, 6:30 AM
It's an easy thing to grasp. The thing is that when working with a typical data model, sorting is carried out on a per-instance basis: Sorting a set of records returned by a query doesn't actually sort those records in the database, but rather orders them in memory. My misunderstanding derives from an expectation that these sets be retrieved independently rather than the store serving as the lone in-memory representation. What's the workaround for this (surely I wouldn't want to create two separate data stores, needlessly returning identical records as this is read-only)?

Mike Robinson
23 Sep 2009, 11:02 AM
A Store object is, in effect, a cache. It holds a range of records that have been retrieved from the host (maybe) and that are being manipulated locally. When, say, a "girid" object asks for "row x through y of ... oh by the way, how-many records are there?" ... the Store object does the work.

It's a reasonable implementation. Remember, though, that the Store object is purpose-built for the other Components that are designed to use it. It's targeted to serve their needs. It's not "an abstract thing."