* Data reader class to create an Array of Roo.data.Record objects from a JSON response
* based on mappings in a provided Roo.data.Record constructor.
*
- * The default behaviour of a store is to send _requestMeta, unless the class has recieved 'metaData' property
+ * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
* in the reply previously.
*
* <p>
* After any data loads, the raw JSON data is available for further custom processing.
* @type Object
*/
- this.jsonData = o;
+ this.o = o;
var s = this.meta, Record = this.recordType,
- f = Record.prototype.fields, fi = f.items, fl = f.length;
+ f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length: 0;
// Generate extraction functions for the totalProperty, the root, the id, and for each field
if (!this.ef) {
if (s.id) {
var g = this.getJsonAccessor(s.id);
this.getId = function(rec) {
- var r = g(rec);
+ var r = g(rec);
return (r === undefined || r === "") ? null : r;
};
} else {
}
}
var records = [];
- for(var i = 0; i < c; i++){
- var n = root[i];
- var values = {};
- var id = this.getId(n);
- for(var j = 0; j < fl; j++){
- f = fi[j];
- var v = this.ef[j](n);
- values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
- }
- var record = new Record(values, id);
- record.json = n;
- records[i] = record;
- }
- return {
- success : success,
- records : records,
- totalRecords : totalRecords
- };
+ for(var i = 0; i < c; i++){
+ var n = root[i];
+ var values = {};
+ var id = this.getId(n);
+ for(var j = 0; j < fl; j++){
+ f = fi[j];
+ var v = this.ef[j](n);
+ if (!f.convert) {
+ Roo.log('missing convert for ' + f.name);
+ Roo.log(f);
+ continue;
+ }
+ values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
+ }
+ var record = new Record(values, id);
+ record.json = n;
+ records[i] = record;
+ }
+ return {
+ raw : o,
+ success : success,
+ records : records,
+ totalRecords : totalRecords
+ };
}
});
\ No newline at end of file