PDA

View Full Version : [FIXED][3.0] JsonReader metaData changes don't rebuild accessors.



hendricd
7 Jul 2009, 11:50 AM
Ext.override(Ext.data.JsonReader,{

/**
* Create a data block containing Ext.data.Records from a JSON object.
* @param {Object} o An object which contains an Array of row objects in the property specified
* in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
* which contains the total size of the dataset.
* @return {Object} data A data block which is used by an Ext.data.Store object as
* a cache of Ext.data.Records.
*/
readRecords : function(o){
/**
* After any data loads, the raw JSON data is available for further custom processing. If no data is
* loaded or there is a load exception this property will be undefined.
* @type Object
*/
this.jsonData = o;
if(o.metaData){
delete this.ef; //killed here
this.meta = o.metaData;
this.recordType = Ext.data.Record.create(o.metaData.fields);
this.buildExtractors();
this.onMetaChange(this.meta, this.recordType, o);
}
var s = this.meta, Record = this.recordType,
f = Record.prototype.fields, fi = f.items, fl = f.length, v;

var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
if(s.totalProperty){
v = parseInt(this.getTotal(o), 10);
if(!isNaN(v)){
totalRecords = v;
}
}
if(s.successProperty){
v = this.getSuccess(o);
if(v === false || v === 'false'){
success = false;
}
}

var records = [];
for(var i = 0; i < c; i++){
var n = root[i];
var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
record.json = n;
records[i] = record;
}
return {
success : success,
records : records,
totalRecords : totalRecords
};
}

});

evant
7 Jul 2009, 7:21 PM
This has been fixed in the trunk, thanks for the report.