/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
rs.phantom = false; // <-- That's what it's all about\r
rs._phid = rs.id; // <-- copy phantom-id -> _phid, so we can remap in Store#onCreateRecords\r
rs.id = this.getId(data);\r
- rs.data = data;\r
+\r
+ rs.fields.each(function(f) {\r
+ if (data[f.name] !== f.defaultValue) {\r
+ rs.data[f.name] = data[f.name];\r
+ }\r
+ });\r
rs.commit();\r
}\r
},\r
data = data.shift();\r
}\r
if (this.isData(data)) {\r
- rs.data = Ext.apply(rs.data, data);\r
+ rs.fields.each(function(f) {\r
+ if (data[f.name] !== f.defaultValue) {\r
+ rs.data[f.name] = data[f.name];\r
+ }\r
+ });\r
}\r
rs.commit();\r
}\r
},\r
\r
+ /**\r
+ * returns extracted, type-cast rows of data. Iterates to call #extractValues for each row\r
+ * @param {Object[]/Object} data-root from server response\r
+ * @param {Boolean} returnRecords [false] Set true to return instances of Ext.data.Record\r
+ * @private\r
+ */\r
+ extractData : function(root, returnRecords) {\r
+ // A bit ugly this, too bad the Record's raw data couldn't be saved in a common property named "raw" or something.\r
+ var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';\r
+\r
+ var rs = [];\r
+\r
+ // Had to add Check for XmlReader, #isData returns true if root is an Xml-object. Want to check in order to re-factor\r
+ // #extractData into DataReader base, since the implementations are almost identical for JsonReader, XmlReader\r
+ if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {\r
+ root = [root];\r
+ }\r
+ var f = this.recordType.prototype.fields,\r
+ fi = f.items,\r
+ fl = f.length,\r
+ rs = [];\r
+ if (returnRecords === true) {\r
+ var Record = this.recordType;\r
+ for (var i = 0; i < root.length; i++) {\r
+ var n = root[i];\r
+ var record = new Record(this.extractValues(n, fi, fl), this.getId(n));\r
+ record[rawName] = n; // <-- There's implementation of ugly bit, setting the raw record-data.\r
+ rs.push(record);\r
+ }\r
+ }\r
+ else {\r
+ for (var i = 0; i < root.length; i++) {\r
+ var data = this.extractValues(root[i], fi, fl);\r
+ data[this.meta.idProperty] = this.getId(root[i]);\r
+ rs.push(data);\r
+ }\r
+ }\r
+ return rs;\r
+ },\r
+\r
/**\r
* Returns true if the supplied data-hash <b>looks</b> and quacks like data. Checks to see if it has a key\r
* corresponding to idProperty defined in your DataReader config containing non-empty pk.\r
'invalid-response': "#readResponse received an invalid response from the server."\r
}\r
});\r
-\r
-\r
-/**\r
- * Ext.data.Response\r
- * A generic response class to normalize response-handling internally to the framework.\r
- * TODO move to own file, add to jsb.\r
- */\r
-Ext.data.Response = function(params) {\r
- Ext.apply(this, params);\r
-};\r
-Ext.data.Response.prototype = {\r
- /**\r
- * @property {String} action {@link Ext.data.Api#actions}\r
- */\r
- action: undefined,\r
- /**\r
- * @property {Boolean} success\r
- */\r
- success : undefined,\r
- /**\r
- * @property {String} message\r
- */\r
- message : undefined,\r
- /**\r
- * @property {Array/Object} data\r
- */\r
- data: undefined,\r
- /**\r
- * @property {Object} raw The raw response returned from server-code\r
- */\r
- raw: undefined,\r
- /**\r
- * @property {Ext.data.Record/Ext.data.Record[]} record(s) related to the Request action\r
- */\r
- records: undefined\r
-}\r