Roo/data/JsonReader.js
[roojs1] / Roo / data / JsonReader.js
index d2ea499..72366b0 100644 (file)
@@ -45,6 +45,7 @@ var myReader = new Roo.data.JsonReader({
  * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
  * @cfg {String} root name of the property which contains the Array of row objects.
  * @cfg {String} id Name of the property within a row object that contains a record identifier value.
+ * @cfg {Array} fields Array of field definition objects
  * @constructor
  * Create a new JsonReader
  * @param {Object} meta Metadata configuration options
@@ -141,7 +142,7 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
          */
         this.o = o;
         var s = this.meta, Record = this.recordType,
-            f = Record ? Record.prototype.fields : null, fi = f.items, fl = f.length;
+            f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
 
 //      Generate extraction functions for the totalProperty, the root, the id, and for each field
         if (!this.ef) {
@@ -169,6 +170,8 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
             }
         }
 
+        Roo.log(o);
+
        var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
        if(s.totalProperty){
             var vt = parseInt(this.getTotal(o), 10);
@@ -202,7 +205,7 @@ Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
             records[i] = record;
         }
         return {
-        raw : o,
+            raw : o,
             success : success,
             records : records,
             totalRecords : totalRecords