Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / output / Ext.data.HasManyAssociation.js
1 Ext.data.JsonP.Ext_data_HasManyAssociation({
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": "Association.html#Ext-data-Association-cfg-associatedModel",
16         "shortDoc": "The string name of the model that is being associated with. ...",
17         "static": false,
18         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
19         "private": false,
20         "name": "associatedModel",
21         "owner": "Ext.data.Association",
22         "doc": "<p>The string name of the model that is being associated with. Required</p>\n",
23         "linenr": 122,
24         "html_filename": "Association.html"
25       },
26       {
27         "type": "String",
28         "deprecated": null,
29         "alias": null,
30         "protected": false,
31         "tagname": "cfg",
32         "href": "Association.html#Ext-data-Association-cfg-associationKey",
33         "shortDoc": "The name of the property in the data to read the association from. ...",
34         "static": false,
35         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
36         "private": false,
37         "name": "associationKey",
38         "owner": "Ext.data.Association",
39         "doc": "<p>The name of the property in the data to read the association from.\nDefaults to the name of the associated model.</p>\n",
40         "linenr": 136,
41         "html_filename": "Association.html"
42       },
43       {
44         "type": "Boolean",
45         "deprecated": null,
46         "alias": null,
47         "protected": false,
48         "tagname": "cfg",
49         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-autoLoad",
50         "shortDoc": "True to automatically load the related store from a remote source when instantiated. ...",
51         "static": false,
52         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
53         "private": false,
54         "name": "autoLoad",
55         "owner": "Ext.data.HasManyAssociation",
56         "doc": "<p>True to automatically load the related store from a remote source when instantiated.\nDefaults to <tt>false</tt>.</p>\n",
57         "linenr": 167,
58         "html_filename": "HasManyAssociation.html"
59       },
60       {
61         "type": "String",
62         "deprecated": null,
63         "alias": null,
64         "protected": false,
65         "tagname": "cfg",
66         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-filterProperty",
67         "shortDoc": "Optionally overrides the default filter that is set up on the associated Store. ...",
68         "static": false,
69         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
70         "private": false,
71         "name": "filterProperty",
72         "owner": "Ext.data.HasManyAssociation",
73         "doc": "<p>Optionally overrides the default filter that is set up on the associated Store. If\nthis is not set, a filter is automatically created which filters the association based on the configured\n<a href=\"#/api/Ext.data.HasManyAssociation-cfg-foreignKey\" rel=\"Ext.data.HasManyAssociation-cfg-foreignKey\" class=\"docClass\">foreignKey</a>. See intro docs for more details. Defaults to undefined</p>\n",
74         "linenr": 161,
75         "html_filename": "HasManyAssociation.html"
76       },
77       {
78         "type": "String",
79         "deprecated": null,
80         "alias": null,
81         "protected": false,
82         "tagname": "cfg",
83         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-foreignKey",
84         "shortDoc": "The name of the foreign key on the associated model that links it to the owner\nmodel. ...",
85         "static": false,
86         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
87         "private": false,
88         "name": "foreignKey",
89         "owner": "Ext.data.HasManyAssociation",
90         "doc": "<p>The name of the foreign key on the associated model that links it to the owner\nmodel. Defaults to the lowercased name of the owner model plus \"_id\", e.g. an association with a where a\nmodel called Group hasMany Users would create 'group_id' as the foreign key. When the remote store is loaded,\nthe store is automatically filtered so that only records with a matching foreign key are included in the\nresulting child store. This can be overridden by specifying the <a href=\"#/api/Ext.data.HasManyAssociation-cfg-filterProperty\" rel=\"Ext.data.HasManyAssociation-cfg-filterProperty\" class=\"docClass\">filterProperty</a>.</p>\n\n<pre><code>Ext.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: 'User'\n});\n\nExt.define('User', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'group_id'], // refers to the id of the group that this user belongs to\n    belongsTo: 'Group'\n});\n</code></pre>\n\n",
91         "linenr": 111,
92         "html_filename": "HasManyAssociation.html"
93       },
94       {
95         "type": "String",
96         "deprecated": null,
97         "alias": null,
98         "protected": false,
99         "tagname": "cfg",
100         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-name",
101         "shortDoc": "The name of the function to create on the owner model to retrieve the child store. ...",
102         "static": false,
103         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
104         "private": false,
105         "name": "name",
106         "owner": "Ext.data.HasManyAssociation",
107         "doc": "<p>The name of the function to create on the owner model to retrieve the child store.\nIf not specified, the pluralized name of the child model is used.</p>\n\n<pre><code>// This will create a users() method on any Group model instance\nExt.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: 'User'\n});\nvar group = new Group();\nconsole.log(group.users());\n\n// The method to retrieve the users will now be getUserList\nExt.define('Group', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name'],\n    hasMany: {model: 'User', name: 'getUserList'}\n});\nvar group = new Group();\nconsole.log(group.getUserList());\n</code></pre>\n\n",
108         "linenr": 132,
109         "html_filename": "HasManyAssociation.html"
110       },
111       {
112         "type": "String",
113         "deprecated": null,
114         "alias": null,
115         "protected": false,
116         "tagname": "cfg",
117         "href": "Association.html#Ext-data-Association-cfg-ownerModel",
118         "shortDoc": "The string name of the model that owns the association. ...",
119         "static": false,
120         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
121         "private": false,
122         "name": "ownerModel",
123         "owner": "Ext.data.Association",
124         "doc": "<p>The string name of the model that owns the association. Required</p>\n",
125         "linenr": 118,
126         "html_filename": "Association.html"
127       },
128       {
129         "type": "String",
130         "deprecated": null,
131         "alias": null,
132         "protected": false,
133         "tagname": "cfg",
134         "href": "Association.html#Ext-data-Association-cfg-primaryKey",
135         "shortDoc": "The name of the primary key on the associated model. ...",
136         "static": false,
137         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
138         "private": false,
139         "name": "primaryKey",
140         "owner": "Ext.data.Association",
141         "doc": "<p>The name of the primary key on the associated model. Defaults to 'id'.\nIn general this will be the <a href=\"#/api/Ext.data.Model-cfg-idProperty\" rel=\"Ext.data.Model-cfg-idProperty\" class=\"docClass\">Ext.data.Model.idProperty</a> of the Model.</p>\n",
142         "linenr": 126,
143         "html_filename": "Association.html"
144       },
145       {
146         "type": "Ext.data.reader.Reader",
147         "deprecated": null,
148         "alias": null,
149         "protected": false,
150         "tagname": "cfg",
151         "href": "Association.html#Ext-data-Association-cfg-reader",
152         "static": false,
153         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
154         "private": false,
155         "name": "reader",
156         "owner": "Ext.data.Association",
157         "doc": "<p>A special reader to read associated data</p>\n",
158         "linenr": 132,
159         "html_filename": "Association.html"
160       },
161       {
162         "type": "Object",
163         "deprecated": null,
164         "alias": null,
165         "protected": false,
166         "tagname": "cfg",
167         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-storeConfig",
168         "shortDoc": "Optional configuration object that will be passed to the generated Store. ...",
169         "static": false,
170         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
171         "private": false,
172         "name": "storeConfig",
173         "owner": "Ext.data.HasManyAssociation",
174         "doc": "<p>Optional configuration object that will be passed to the generated Store. Defaults to\nundefined.</p>\n",
175         "linenr": 156,
176         "html_filename": "HasManyAssociation.html"
177       },
178       {
179         "type": "String",
180         "deprecated": null,
181         "alias": null,
182         "protected": false,
183         "tagname": "cfg",
184         "href": "HasManyAssociation.html#Ext-data-HasManyAssociation-cfg-type",
185         "shortDoc": "The type configuration can be used when creating associations using a configuration object. ...",
186         "static": false,
187         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
188         "private": false,
189         "name": "type",
190         "owner": "Ext.data.HasManyAssociation",
191         "doc": "<p>The type configuration can be used when creating associations using a configuration object.\nUse 'hasMany' to create a HasManyAssocation</p>\n\n<pre><code>associations: [{\n    type: 'hasMany',\n    model: 'User'\n}]\n</code></pre>\n\n",
192         "linenr": 172,
193         "html_filename": "HasManyAssociation.html"
194       }
195     ],
196     "method": [
197       {
198         "deprecated": null,
199         "alias": null,
200         "href": "Association.html#Ext-data-Association-method-constructor",
201         "tagname": "method",
202         "protected": false,
203         "shortDoc": "Creates the Association object. ...",
204         "static": false,
205         "params": [
206           {
207             "type": "Object",
208             "optional": true,
209             "doc": "<p>(optional) Config object.</p>\n",
210             "name": "config"
211           }
212         ],
213         "private": false,
214         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
215         "doc": "<p>Creates the Association object.</p>\n",
216         "owner": "Ext.data.Association",
217         "name": "HasManyAssociation",
218         "html_filename": "Association.html",
219         "return": {
220           "type": "Object",
221           "doc": "\n"
222         },
223         "linenr": 170
224       },
225       {
226         "deprecated": null,
227         "alias": null,
228         "protected": false,
229         "tagname": "method",
230         "href": "Association.html#Ext-data-Association-method-getReader",
231         "shortDoc": "Get a specialized reader for reading associated data ...",
232         "static": false,
233         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
234         "private": false,
235         "params": [
236
237         ],
238         "name": "getReader",
239         "owner": "Ext.data.Association",
240         "doc": "<p>Get a specialized reader for reading associated data</p>\n",
241         "linenr": 214,
242         "return": {
243           "type": "Ext.data.reader.Reader",
244           "doc": "<p>The reader, null if not supplied</p>\n"
245         },
246         "html_filename": "Association.html"
247       }
248     ],
249     "property": [
250       {
251         "type": "String",
252         "deprecated": null,
253         "alias": null,
254         "protected": false,
255         "tagname": "property",
256         "href": "Association.html#Ext-data-Association-property-associatedName",
257         "shortDoc": "The name of the model is on the other end of the association (e.g. ...",
258         "static": false,
259         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
260         "private": false,
261         "name": "associatedName",
262         "owner": "Ext.data.Association",
263         "doc": "<p>The name of the model is on the other end of the association (e.g. if a User model hasMany Orders, this is 'Order')</p>\n",
264         "linenr": 202,
265         "html_filename": "Association.html"
266       },
267       {
268         "type": "String",
269         "deprecated": null,
270         "alias": null,
271         "protected": false,
272         "tagname": "property",
273         "href": "Association.html#Ext-data-Association-property-ownerName",
274         "static": false,
275         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js",
276         "private": false,
277         "name": "ownerName",
278         "owner": "Ext.data.Association",
279         "doc": "<p>The name of the model that 'owns' the association</p>\n",
280         "linenr": 196,
281         "html_filename": "Association.html"
282       }
283     ],
284     "cssVar": [
285
286     ],
287     "cssMixin": [
288
289     ],
290     "event": [
291
292     ]
293   },
294   "singleton": false,
295   "alias": null,
296   "superclasses": [
297     "Ext.data.Association"
298   ],
299   "protected": false,
300   "tagname": "class",
301   "mixins": [
302
303   ],
304   "href": "HasManyAssociation.html#Ext-data-HasManyAssociation",
305   "subclasses": [
306
307   ],
308   "static": false,
309   "author": "Ed Spencer",
310   "component": false,
311   "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/HasManyAssociation.js",
312   "private": false,
313   "alternateClassNames": [
314
315   ],
316   "name": "Ext.data.HasManyAssociation",
317   "doc": "<p>Represents a one-to-many relationship between two models. Usually created indirectly via a model definition:</p>\n\n\n\n\n<pre><code>Ext.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',      type: 'int'},\n        {name: 'user_id', type: 'int'},\n        {name: 'name',    type: 'string'}\n    ]\n});\n\nExt.define('User', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',   type: 'int'},\n        {name: 'name', type: 'string'}\n    ],\n    // we can use the hasMany shortcut on the model to create a hasMany association\n    hasMany: {model: 'Product', name: 'products'}\n});\n</pre>\n\n\n<p></code></p>\n\n<p>Above we created Product and User models, and linked them by saying that a User hasMany Products. This gives\nus a new function on every User instance, in this case the function is called 'products' because that is the name\nwe specified in the association configuration above.</p>\n\n\n\n\n<p>This new function returns a specialized <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a> which is automatically filtered to load\nonly Products for the given model instance:</p>\n\n\n\n\n<pre><code>//first, we load up a User with id of 1\nvar user = Ext.ModelManager.create({id: 1, name: 'Ed'}, 'User');\n\n//the user.products function was created automatically by the association and returns a <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a>\n//the created store is automatically scoped to the set of Products for the User with id of 1\nvar products = user.products();\n\n//we still have all of the usual Store functions, for example it's easy to add a Product for this User\nproducts.add({\n    name: 'Another Product'\n});\n\n//saves the changes to the store - this automatically sets the new Product's user_id to 1 before saving\nproducts.sync();\n</code></pre>\n\n\n\n\n<p>The new Store is only instantiated the first time you call products() to conserve memory and processing time,\nthough calling products() a second time returns the same store instance.</p>\n\n\n\n\n<p><u>Custom filtering</u></p>\n\n\n\n\n<p>The Store is automatically furnished with a filter - by default this filter tells the store to only return\nrecords where the associated model's foreign key matches the owner model's primary key. For example, if a User\nwith ID = 100 hasMany Products, the filter loads only Products with user_id == 100.</p>\n\n\n\n\n<p>Sometimes we want to filter by another field - for example in the case of a Twitter search application we may\nhave models for Search and Tweet:</p>\n\n\n\n\n<pre><code>Ext.define('Search', {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'query'\n    ],\n\n    hasMany: {\n        model: 'Tweet',\n        name : 'tweets',\n        filterProperty: 'query'\n    }\n});\n\nExt.define('Tweet', {\n    extend: 'Ext.data.Model',\n    fields: [\n        'id', 'text', 'from_user'\n    ]\n});\n\n//returns a Store filtered by the filterProperty\nvar store = new Search({query: 'Sencha Touch'}).tweets();\n</code></pre>\n\n\n\n\n<p>The tweets association above is filtered by the query property by setting the <a href=\"#/api/Ext.data.HasManyAssociation-cfg-filterProperty\" rel=\"Ext.data.HasManyAssociation-cfg-filterProperty\" class=\"docClass\">filterProperty</a>, and is\nequivalent to this:</p>\n\n\n\n\n<pre><code>var store = new Ext.data.Store({\n    model: 'Tweet',\n    filters: [\n        {\n            property: 'query',\n            value   : 'Sencha Touch'\n        }\n    ]\n});\n</code></pre>\n\n",
318   "mixedInto": [
319
320   ],
321   "linenr": 1,
322   "xtypes": [
323
324   ],
325   "html_filename": "HasManyAssociation.html",
326   "extends": "Ext.data.Association"
327 });