PDA

View Full Version : Ext.data.Store -- onCreateRecords



johnathanhebert
18 Feb 2011, 9:02 AM
The call to this.reader.realize(rs, data) causes rs and data to always end up as empty arrays (after reader.realize() recursively calls itself and splices the arrays down to 0 items), and therefore the following call to this.reMap(rs) always passes an empty array, so records are not properly remapped from their phantom id to their id passed from the server in the data object

When I replace each parameter to realize() with a copy of the array, it works for me.

See the screenshots from firebug where you see the values of rs and data using the original code, and then rs and data using the new code... with the original code, rs always is passed to reMap() as an empty array... is this a bug?



Ext.override(Ext.data.Store, {
onCreateRecords : function(success, rs, data) {
if (success === true) {
try {
/* REPLACE EACH ARGUMENT TO this.reader.realize WITH A COPY OF THE ARRAY */
/* ORIGINAL */ //this.reader.realize(rs, data);
/* OVERRIDE */ this.reader.realize([].concat(rs), [].concat(data));
this.reMap(rs);
}
catch (e) {
this.handleException(e);
if (Ext.isArray(rs)) {
// Recurse to run back into the try {}. DataReader#realize splices-off the rs until empty.
this.onCreateRecords(success, rs, data);
}
}
}
}
});

Condor
18 Feb 2011, 9:14 AM
Duplicate of this bugreport (http://www.sencha.com/forum/showthread.php?105442-FIXED-1158-3.2-DataReader.onCreateRecords-doesn-t-reMap-for-mutiple-records) (fixed in Ext 3.3.2).

Also, your code doesn't handle partial creation interrupted by an error.

johnathanhebert
18 Feb 2011, 9:18 AM
Thanks Condor