X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/source/Array2.html diff --git a/docs/source/Array2.html b/docs/source/Array2.html index 567dbb95..37655388 100644 --- a/docs/source/Array2.html +++ b/docs/source/Array2.html @@ -1,828 +1,88 @@ -Sencha Documentation Project
/**
- * @author Jacky Nguyen <jacky@sencha.com>
- * @docauthor Jacky Nguyen <jacky@sencha.com>
- * @class Ext.Array
- *
- * A set of useful static methods to deal with arrays; provide missing methods for older browsers.
-
- * @singleton
- * @markdown
- */
-(function() {
-
-    var arrayPrototype = Array.prototype,
-        slice = arrayPrototype.slice,
-        supportsForEach = 'forEach' in arrayPrototype,
-        supportsMap = 'map' in arrayPrototype,
-        supportsIndexOf = 'indexOf' in arrayPrototype,
-        supportsEvery = 'every' in arrayPrototype,
-        supportsSome = 'some' in arrayPrototype,
-        supportsFilter = 'filter' in arrayPrototype,
-        supportsSort = function() {
-            var a = [1,2,3,4,5].sort(function(){ return 0; });
-            return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
-        }(),
-        supportsSliceOnNodeList = true,
-        ExtArray;
-    try {
-        // IE 6 - 8 will throw an error when using Array.prototype.slice on NodeList
-        if (typeof document !== 'undefined') {
-            slice.call(document.getElementsByTagName('body'));
-        }
-    } catch (e) {
-        supportsSliceOnNodeList = false;
+
+
+
+  
+  The source code
+  
+  
+  
+  
+
+
+  
/**
+ * @author Ed Spencer
+ * @class Ext.data.reader.Array
+ * @extends Ext.data.reader.Json
+ * 
+ * <p>Data reader class to create an Array of {@link Ext.data.Model} 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 <code>mapping</code> property
+ * of the field definition if it exists, or the field's ordinal position in the definition.</p>
+ * 
+ * <p><u>Example code:</u></p>
+ * 
+<pre><code>
+Employee = Ext.define('Employee', {
+    extend: 'Ext.data.Model',
+    fields: [
+        'id',
+        {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.reader.Array({
+    model: 'Employee'
+}, Employee);
+</code></pre>
+ * 
+ * <p>This would consume an Array like this:</p>
+ * 
+<pre><code>
+[ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
+</code></pre>
+ * 
+ * @constructor
+ * Create a new ArrayReader
+ * @param {Object} meta Metadata configuration options.
+ */
+Ext.define('Ext.data.reader.Array', {
+    extend: 'Ext.data.reader.Json',
+    alternateClassName: 'Ext.data.ArrayReader',
+    alias : 'reader.array',
+
+    /**
+     * @private
+     * Most of the work is done for us by JsonReader, but we need to overwrite the field accessors to just
+     * reference the correct position in the array.
      */
-    Ext.toArray = function() {
-        return ExtArray.toArray.apply(ExtArray, arguments);
+    buildExtractors: function() {
+        this.callParent(arguments);
+        
+        var fields = this.model.prototype.fields.items,
+            i = 0,
+            length = fields.length,
+            extractorFunctions = [],
+            map;
+        
+        for (; i < length; i++) {
+            map = fields[i].mapping;
+            extractorFunctions.push(function(index) {
+                return function(data) {
+                    return data[index];
+                };
+            }(map !== null ? map : i));
+        }
+        
+        this.extractorFunctions = extractorFunctions;
     }
-})();
-
\ No newline at end of file +}); +
+ +