PDA

View Full Version : [OPEN-1133] Store#reMap method and filtered Stores



wprater
16 Jul 2010, 12:04 PM
Hi,

I posted this in General Help, but figured this is a better place for it.

Is there any reason why #reMap does not affect this.snapshot as well?

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++) {
this.reMap(record[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);
}
}
},

Condor
17 Jul 2010, 6:38 AM
I've reported this before (http://www.sencha.com/forum/showthread.php?97566-DISCUSS-Issues-with-filtered-records) (together with some other filtering related problems).