View Full Version : Store#reMap method and filtered Stores BUG?

14 Jul 2010, 7:09 PM

I've already filtered the Store, so this.snapshot exists. Let's say we just created a new record and the success handler is called, thus calling #onCreateRecords, #realize and #reMap. When #reMap is called, it only affects the this.data property or what could be filtered data. It should also update the snapshot if it exists, correct? If this is not desired behavior, there could be a bug as one is not able to Store#getById on newly created records. Store#getById uses a preference for this.snapshot (original or saved?) data and will never find the new record.

Here is a potential fix (untested):

reMap : function(record) {
if (Ext.isArray(record)) {
for (var i = 0, len = record.length; i < len; i++) {
} else {
function alterHashMap(data, record) {
delete data[record._phid];
data[record.id] = record;
var index = data.keys.indexOf(record._phid);
data.keys.splice(index, 1, record.id);
delete record._phid;
alterHashMap(this.data, record);
if (this.snapshot) {
alterHashMap(this.snapshot, record);