You found a bug! We've classified it as
EXTJS-5647
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha Premium Member
Store Sync Bug when using Filter
Ext 4.0.7, all browsers
In Store (AbstractStore) I am calling the sync function to tell the store to persist changed data (I am storing data locally). Generally, this works fine, but there are fringe cases.
If I have a filter on the store and I programmatically update a record which is fitlered out, then that record is never updated. The reason being that the sync method calls getUpdatedRecords;
getUpdatedRecords: function() {
return this.data.filterBy(this.filterUpdated).items;
},
The problem is that getUpdatedRecords uses this.data instead of this.snapshot. This seems like a bug since there are few, if any cases, where you want your filter applied to your communication with the proxy.
-
I would agree with you that it should check to see if this.snapshot exists and use it if it does, if not then use this.data.
I will transfer this thread to the bugs forum to enter into our tracking system.
-
Hi everybody,
It looks to be by design according to this note
When store is filtered, most of the methods for accessing store data will be working only within the set of filtered records. Two notable exceptions are queryBy and getById.
here
http://docs.sencha.com/extjs/4.2.1/#...-method-filter
Actually, the sync method works with a set of filtered method.
Well, this decision is quite controversial. I mean syncing filtered records only. A user searches in the grid for some record using filters, edit a found record, search for another one, edit it, ..., and press a Save button. For sure he expects all the records to be saved. Probably, saving filtering records only could make sense. Though I could not imagine any scenario. However, I don't state there is no one.
I think making a global option for a Store could be a solution. Like "syncFilteredOnly" (dislike the name, there should be better one) which is supposed to be false by default.
@mitchellsimoens, is there any update on this issue? What do the designers of the Data package think about it?
-
Sencha Premium Member
It seems this was "fixed" in 4.2.2 `EXTJSIV-5647 Filtered out records are missing from new and modified collection to sync.`
which addresses the behaviour of *not* wanting the filter to apply to the sync.
But we have code that relied on using the filter to only sync the selected items - how are we meant to do that now?