javascripts/basepack.js in netzke-basepack-0.2.0.1 vs javascripts/basepack.js in netzke-basepack-0.2.2

- old
+ new

@@ -47,6 +47,36 @@ text_field:'String', datetime:'String', checkbox:'Boolean', combo_box:'String', date:'Date' -} +} + +Ext.data.RecordArrayReader = Ext.extend(Ext.data.JsonReader, { + /** + * Create a data block containing Ext.data.Records from an Array. + * @param {Object} o An Array of row objects which represents the dataset. + * @return {Object} data A data block which is used by an Ext.data.Store object as + * a cache of Ext.data.Records. + */ + readRecord : function(o){ + var sid = this.meta ? this.meta.id : null; + var recordType = this.recordType, fields = recordType.prototype.fields; + var records = []; + var root = o; + // for(var i = 0; i < root.length; i++){ + var n = root; + var values = {}; + var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null); + for(var j = 0, jlen = fields.length; j < jlen; j++){ + var f = fields.items[j]; + var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j; + var v = n[k] !== undefined ? n[k] : f.defaultValue; + v = f.convert(v, n); + values[f.name] = v; + } + var record = new recordType(values, id); + record.json = n; + // } + return record; + } +}); \ No newline at end of file