Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / output / Ext.data.reader.Reader.js
1 Ext.data.JsonP.Ext_data_reader_Reader({
2   "allMixins": [
3
4   ],
5   "deprecated": null,
6   "docauthor": null,
7   "members": {
8     "cfg": [
9       {
10         "type": "String",
11         "deprecated": null,
12         "alias": null,
13         "protected": false,
14         "tagname": "cfg",
15         "href": "Reader.html#Ext-data-reader-Reader-cfg-idProperty",
16         "shortDoc": "Name of the property within a row object\nthat contains a record identifier value. ...",
17         "static": false,
18         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
19         "private": false,
20         "name": "idProperty",
21         "owner": "Ext.data.reader.Reader",
22         "doc": "<p>Name of the property within a row object\nthat contains a record identifier value.  Defaults to <tt>The id of the model</tt>.\nIf an idProperty is explicitly specified it will override that of the one specified\non the model</p>\n",
23         "linenr": 151,
24         "html_filename": "Reader.html"
25       },
26       {
27         "type": "Boolean",
28         "deprecated": null,
29         "alias": null,
30         "protected": false,
31         "tagname": "cfg",
32         "href": "Reader.html#Ext-data-reader-Reader-cfg-implicitIncludes",
33         "shortDoc": "True to automatically parse models nested within other models in a response\nobject. ...",
34         "static": false,
35         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
36         "private": false,
37         "name": "implicitIncludes",
38         "owner": "Ext.data.reader.Reader",
39         "doc": "<p>True to automatically parse models nested within other models in a response\nobject. See the <a href=\"#/api/Ext.data.reader.Reader\" rel=\"Ext.data.reader.Reader\" class=\"docClass\">Ext.data.reader.Reader</a> intro docs for full explanation. Defaults to true.</p>\n",
40         "linenr": 188,
41         "html_filename": "Reader.html"
42       },
43       {
44         "type": "String",
45         "deprecated": null,
46         "alias": null,
47         "protected": false,
48         "tagname": "cfg",
49         "href": "Reader.html#Ext-data-reader-Reader-cfg-messageProperty",
50         "shortDoc": "The name of the property which contains a response message. ...",
51         "static": false,
52         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
53         "private": false,
54         "name": "messageProperty",
55         "owner": "Ext.data.reader.Reader",
56         "doc": "<p>The name of the property which contains a response message.\nThis property is optional.</p>\n",
57         "linenr": 183,
58         "html_filename": "Reader.html"
59       },
60       {
61         "type": "String",
62         "deprecated": null,
63         "alias": null,
64         "protected": false,
65         "tagname": "cfg",
66         "href": "Reader.html#Ext-data-reader-Reader-cfg-root",
67         "shortDoc": "Required. ...",
68         "static": false,
69         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
70         "private": false,
71         "name": "root",
72         "owner": "Ext.data.reader.Reader",
73         "doc": "<p><b>Required</b>.  The name of the property\nwhich contains the Array of row objects.  Defaults to <tt>undefined</tt>.\nAn exception will be thrown if the root property is undefined. The data\npacket value for this property should be an empty array to clear the data\nor show no data.</p>\n",
74         "linenr": 174,
75         "html_filename": "Reader.html"
76       },
77       {
78         "type": "String",
79         "deprecated": null,
80         "alias": null,
81         "protected": false,
82         "tagname": "cfg",
83         "href": "Reader.html#Ext-data-reader-Reader-cfg-successProperty",
84         "shortDoc": "Name of the property from which to\nretrieve the success attribute. ...",
85         "static": false,
86         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
87         "private": false,
88         "name": "successProperty",
89         "owner": "Ext.data.reader.Reader",
90         "doc": "<p>Name of the property from which to\nretrieve the success attribute. Defaults to <tt>success</tt>.  See\n<a href=\"#/api/Ext.data.proxy.Proxy\" rel=\"Ext.data.proxy.Proxy\" class=\"docClass\">Ext.data.proxy.Proxy</a>.exception\nfor additional information.</p>\n",
91         "linenr": 166,
92         "html_filename": "Reader.html"
93       },
94       {
95         "type": "String",
96         "deprecated": null,
97         "alias": null,
98         "protected": false,
99         "tagname": "cfg",
100         "href": "Reader.html#Ext-data-reader-Reader-cfg-totalProperty",
101         "shortDoc": "Name of the property from which to\nretrieve the total number of records in the dataset. ...",
102         "static": false,
103         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
104         "private": false,
105         "name": "totalProperty",
106         "owner": "Ext.data.reader.Reader",
107         "doc": "<p>Name of the property from which to\nretrieve the total number of records in the dataset. This is only needed\nif the whole dataset is not passed in one go, but is being paged from\nthe remote server.  Defaults to <tt>total</tt>.</p>\n",
108         "linenr": 158,
109         "html_filename": "Reader.html"
110       }
111     ],
112     "method": [
113       {
114         "deprecated": null,
115         "alias": null,
116         "href": "Reader.html#Ext-data-reader-Reader-method-constructor",
117         "tagname": "method",
118         "protected": false,
119         "shortDoc": "Creates new Reader. ...",
120         "static": false,
121         "params": [
122           {
123             "type": "Object",
124             "optional": true,
125             "doc": "<p>(optional) Config object.</p>\n",
126             "name": "config"
127           }
128         ],
129         "private": false,
130         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
131         "doc": "<p>Creates new Reader.</p>\n",
132         "owner": "Ext.data.reader.Reader",
133         "name": "Reader",
134         "html_filename": "Reader.html",
135         "return": {
136           "type": "Object",
137           "doc": "\n"
138         },
139         "linenr": 196
140       },
141       {
142         "deprecated": null,
143         "alias": null,
144         "protected": false,
145         "tagname": "method",
146         "href": "Reader.html#Ext-data-reader-Reader-method-getResponseData",
147         "shortDoc": "Takes a raw response object (as passed to this.read) and returns the useful data segment of it. ...",
148         "static": false,
149         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
150         "private": false,
151         "params": [
152           {
153             "type": "Object",
154             "optional": false,
155             "doc": "<p>The responce object</p>\n",
156             "name": "response"
157           }
158         ],
159         "name": "getResponseData",
160         "owner": "Ext.data.reader.Reader",
161         "doc": "<p>Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemented by each subclass</p>\n",
162         "linenr": 460,
163         "return": {
164           "type": "Object",
165           "doc": "<p>The useful data from the response</p>\n"
166         },
167         "html_filename": "Reader.html"
168       },
169       {
170         "deprecated": null,
171         "alias": null,
172         "protected": false,
173         "tagname": "method",
174         "href": "Reader.html#Ext-data-reader-Reader-method-read",
175         "shortDoc": "Reads the given response object. ...",
176         "static": false,
177         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
178         "private": false,
179         "params": [
180           {
181             "type": "Object",
182             "optional": false,
183             "doc": "<p>The response object. This may be either an XMLHttpRequest object or a plain JS object</p>\n",
184             "name": "response"
185           }
186         ],
187         "name": "read",
188         "owner": "Ext.data.reader.Reader",
189         "doc": "<p>Reads the given response object. This method normalizes the different types of response object that may be passed\nto it, before handing off the reading of records to the <a href=\"#/api/Ext.data.reader.Reader-method-readRecords\" rel=\"Ext.data.reader.Reader-method-readRecords\" class=\"docClass\">readRecords</a> function.</p>\n",
190         "linenr": 228,
191         "return": {
192           "type": "Ext.data.ResultSet",
193           "doc": "<p>The parsed ResultSet object</p>\n"
194         },
195         "html_filename": "Reader.html"
196       },
197       {
198         "deprecated": null,
199         "alias": null,
200         "protected": false,
201         "tagname": "method",
202         "href": "Reader.html#Ext-data-reader-Reader-method-readRecords",
203         "shortDoc": "Abstracts common functionality used by all Reader subclasses. ...",
204         "static": false,
205         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
206         "private": false,
207         "params": [
208           {
209             "type": "Mixed",
210             "optional": false,
211             "doc": "<p>The raw data object</p>\n",
212             "name": "data"
213           }
214         ],
215         "name": "readRecords",
216         "owner": "Ext.data.reader.Reader",
217         "doc": "<p>Abstracts common functionality used by all Reader subclasses. Each subclass is expected to call\nthis function before running its own logic and returning the <a href=\"#/api/Ext.data.ResultSet\" rel=\"Ext.data.ResultSet\" class=\"docClass\">Ext.data.ResultSet</a> instance. For most\nReaders additional processing should not be needed.</p>\n",
218         "linenr": 248,
219         "return": {
220           "type": "Ext.data.ResultSet",
221           "doc": "<p>A ResultSet object</p>\n"
222         },
223         "html_filename": "Reader.html"
224       }
225     ],
226     "property": [
227       {
228         "type": "Mixed",
229         "deprecated": null,
230         "alias": null,
231         "protected": false,
232         "tagname": "property",
233         "href": "Reader.html#Ext-data-reader-Reader-property-rawData",
234         "shortDoc": "The raw data object that was last passed to readRecords. ...",
235         "static": false,
236         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
237         "private": false,
238         "name": "rawData",
239         "owner": "Ext.data.reader.Reader",
240         "doc": "<p>The raw data object that was last passed to readRecords. Stored for further processing if needed</p>\n",
241         "linenr": 268,
242         "html_filename": "Reader.html"
243       }
244     ],
245     "cssVar": [
246
247     ],
248     "cssMixin": [
249
250     ],
251     "event": [
252
253     ]
254   },
255   "singleton": false,
256   "alias": null,
257   "superclasses": [
258
259   ],
260   "protected": false,
261   "tagname": "class",
262   "mixins": [
263
264   ],
265   "href": "Reader.html#Ext-data-reader-Reader",
266   "subclasses": [
267     "Ext.data.reader.Xml",
268     "Ext.data.reader.Json"
269   ],
270   "static": false,
271   "author": "Ed Spencer",
272   "component": false,
273   "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
274   "private": false,
275   "alternateClassNames": [
276     "Ext.data.Reader",
277     "Ext.data.DataReader"
278   ],
279   "name": "Ext.data.reader.Reader",
280   "doc": "<p>Readers are used to interpret data to be loaded into a <a href=\"#/api/Ext.data.Model\" rel=\"Ext.data.Model\" class=\"docClass\">Model</a> instance or a <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a>\n- usually in response to an AJAX request. This is normally handled transparently by passing some configuration to either the \n<a href=\"#/api/Ext.data.Model\" rel=\"Ext.data.Model\" class=\"docClass\">Model</a> or the <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a> in question - see their documentation for further details.</p>\n\n\n\n\n<p><u>Loading Nested Data</u></p>\n\n\n\n\n<p>Readers have the ability to automatically load deeply-nested data objects based on the <a href=\"#/api/Ext.data.Association\" rel=\"Ext.data.Association\" class=\"docClass\">associations</a>\nconfigured on each Model. Below is an example demonstrating the flexibility of these associations in a fictional CRM system which\nmanages a User, their Orders, OrderItems and Products. First we'll define the models:\n\n<pre><code>Ext.define(\"User\", {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'name'\n    ],\n\n    hasMany: {model: 'Order', name: 'orders'},\n\n    proxy: {\n        type: 'rest',\n        url : 'users.json',\n        reader: {\n            type: 'json',\n            root: 'users'\n        }\n    }\n});\n\nExt.define(\"Order\", {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'total'\n    ],\n\n    hasMany  : {model: 'OrderItem', name: 'orderItems', associationKey: 'order_items'},\n    belongsTo: 'User'\n});\n\nExt.define(\"OrderItem\", {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'price', 'quantity', 'order_id', 'product_id'\n    ],\n\n    belongsTo: ['Order', {model: 'Product', associationKey: 'product'}]\n});\n\nExt.define(\"Product\", {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'name'\n    ],\n\n    hasMany: 'OrderItem'\n});\n</code></pre>\n\n<p>This may be a lot to take in - basically a User has many Orders, each of which is composed of several OrderItems. Finally,\neach OrderItem has a single Product. This allows us to consume data like this:</p>\n\n<pre><code>{\n    \"users\": [\n        {\n            \"id\": 123,\n            \"name\": \"Ed\",\n            \"orders\": [\n                {\n                    \"id\": 50,\n                    \"total\": 100,\n                    \"order_items\": [\n                        {\n                            \"id\"      : 20,\n                            \"price\"   : 40,\n                            \"quantity\": 2,\n                            \"product\" : {\n                                \"id\": 1000,\n                                \"name\": \"MacBook Pro\"\n                            }\n                        },\n                        {\n                            \"id\"      : 21,\n                            \"price\"   : 20,\n                            \"quantity\": 3,\n                            \"product\" : {\n                                \"id\": 1001,\n                                \"name\": \"iPhone\"\n                            }\n                        }\n                    ]\n                }\n            ]\n        }\n    ]\n}\n</code></pre>\n\n<p>The JSON response is deeply nested - it returns all Users (in this case just 1 for simplicity's sake), all of the Orders\nfor each User (again just 1 in this case), all of the OrderItems for each Order (2 order items in this case), and finally\nthe Product associated with each OrderItem. Now we can read the data and use it as follows:\n\n<pre><code>var store = new Ext.data.Store({\n    model: \"User\"\n});\n\nstore.load({\n    callback: function() {\n        //the user that was loaded\n        var user = store.first();\n\n        console.log(\"Orders for \" + user.get('name') + \":\")\n\n        //iterate over the Orders for each User\n        user.orders().each(function(order) {\n            console.log(\"Order ID: \" + order.getId() + \", which contains items:\");\n\n            //iterate over the OrderItems for each Order\n            order.orderItems().each(function(orderItem) {\n                //we know that the Product data is already loaded, so we can use the synchronous getProduct\n                //usually, we would use the asynchronous version (see <a href=\"#/api/Ext.data.BelongsToAssociation\" rel=\"Ext.data.BelongsToAssociation\" class=\"docClass\">Ext.data.BelongsToAssociation</a>)\n                var product = orderItem.getProduct();\n\n                console.log(orderItem.get('quantity') + ' orders of ' + product.get('name'));\n            });\n        });\n    }\n});\n</code></pre>\n\n<p>Running the code above results in the following:</p>\n\n<pre><code>Orders for Ed:\nOrder ID: 50, which contains items:\n2 orders of MacBook Pro\n3 orders of iPhone\n</code></pre>\n\n",
281   "mixedInto": [
282
283   ],
284   "linenr": 1,
285   "xtypes": [
286
287   ],
288   "html_filename": "Reader.html",
289   "extends": "Object"
290 });