X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/source/data/ArrayReader.js diff --git a/source/data/ArrayReader.js b/source/data/ArrayReader.js deleted file mode 100644 index c93182a6..00000000 --- a/source/data/ArrayReader.js +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Ext JS Library 2.2.1 - * Copyright(c) 2006-2009, Ext JS, LLC. - * licensing@extjs.com - * - * http://extjs.com/license - */ - -/** - * @class Ext.data.ArrayReader - * @extends Ext.data.JsonReader - * Data reader class to create an Array of {@link Ext.data.Record} objects from an Array. - * Each element of that Array represents a row of data fields. The - * fields are pulled into a Record object using as a subscript, the mapping property - * of the field definition if it exists, or the field's ordinal position in the definition.
- *

- * Example code:. - *


-var Employee = Ext.data.Record.create([
-    {name: 'name', mapping: 1},         // "mapping" only needed if an "id" field is present which
-    {name: 'occupation', mapping: 2}    // precludes using the ordinal position as the index.
-]);
-var myReader = new Ext.data.ArrayReader({
-    id: 0                     // The subscript within row Array that provides an ID for the Record (optional)
-}, Employee);
-
- *

- * This would consume an Array like this: - *


-[ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
-  
- * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record - * @constructor - * Create a new ArrayReader - * @param {Object} meta Metadata configuration options. - * @param {Object} recordType Either an Array of field definition objects - * as specified to {@link Ext.data.Record#create}, - * or a {@link Ext.data.Record Record} constructor - * created using {@link Ext.data.Record#create}. - */ -Ext.data.ArrayReader = 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. - */ - readRecords : 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[i]; - 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; - records[records.length] = record; - } - return { - records : records, - totalRecords : records.length - }; - } -}); \ No newline at end of file