1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-data.reader.Array-method-constructor'><span id='Ext-data.reader.Array'>/**
2 </span></span> * @author Ed Spencer
3 * @class Ext.data.reader.Array
4 * @extends Ext.data.reader.Json
6 * <p>Data reader class to create an Array of {@link Ext.data.Model} objects from an Array.
7 * Each element of that Array represents a row of data fields. The
8 * fields are pulled into a Record object using as a subscript, the <code>mapping</code> property
9 * of the field definition if it exists, or the field's ordinal position in the definition.</p>
11 * <p><u>Example code:</u></p>
13 <pre><code>
14 Employee = Ext.define('Employee', {
15 extend: 'Ext.data.Model',
18 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
19 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
23 var myReader = new Ext.data.reader.Array({
26 </code></pre>
28 * <p>This would consume an Array like this:</p>
30 <pre><code>
31 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
32 </code></pre>
35 * Create a new ArrayReader
36 * @param {Object} meta Metadata configuration options.
38 Ext.define('Ext.data.reader.Array', {
39 extend: 'Ext.data.reader.Json',
40 alternateClassName: 'Ext.data.ArrayReader',
41 alias : 'reader.array',
43 <span id='Ext-data.reader.Array-method-buildExtractors'> /**
45 * Most of the work is done for us by JsonReader, but we need to overwrite the field accessors to just
46 * reference the correct position in the array.
48 buildExtractors: function() {
49 this.callParent(arguments);
51 var fields = this.model.prototype.fields.items,
52 length = fields.length,
53 extractorFunctions = [],
56 for (i = 0; i < length; i++) {
57 extractorFunctions.push(function(index) {
58 return function(data) {
61 }(fields[i].mapping || i));
64 this.extractorFunctions = extractorFunctions;
67 </pre></pre></body></html>