4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-data-reader-Array-method-constructor'><span id='Ext-data-reader-Array'>/**
19 </span></span> * @author Ed Spencer
20 * @class Ext.data.reader.Array
21 * @extends Ext.data.reader.Json
23 * <p>Data reader class to create an Array of {@link Ext.data.Model} objects from an Array.
24 * Each element of that Array represents a row of data fields. The
25 * fields are pulled into a Record object using as a subscript, the <code>mapping</code> property
26 * of the field definition if it exists, or the field's ordinal position in the definition.</p>
28 * <p><u>Example code:</u></p>
30 <pre><code>
31 Employee = Ext.define('Employee', {
32 extend: 'Ext.data.Model',
35 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
36 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
40 var myReader = new Ext.data.reader.Array({
43 </code></pre>
45 * <p>This would consume an Array like this:</p>
47 <pre><code>
48 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
49 </code></pre>
52 * Create a new ArrayReader
53 * @param {Object} meta Metadata configuration options.
55 Ext.define('Ext.data.reader.Array', {
56 extend: 'Ext.data.reader.Json',
57 alternateClassName: 'Ext.data.ArrayReader',
58 alias : 'reader.array',
60 <span id='Ext-data-reader-Array-method-buildExtractors'> /**
62 * Most of the work is done for us by JsonReader, but we need to overwrite the field accessors to just
63 * reference the correct position in the array.
65 buildExtractors: function() {
66 this.callParent(arguments);
68 var fields = this.model.prototype.fields.items,
69 length = fields.length,
70 extractorFunctions = [],
73 for (i = 0; i < length; i++) {
74 extractorFunctions.push(function(index) {
75 return function(data) {
78 }(fields[i].mapping || i));
81 this.extractorFunctions = extractorFunctions;