X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/3789b528d8dd8aad4558e38e22d775bcab1cbd36..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/output/Ext.data.BelongsToAssociation.js diff --git a/docs/output/Ext.data.BelongsToAssociation.js b/docs/output/Ext.data.BelongsToAssociation.js index 8d3e7109..195ed826 100644 --- a/docs/output/Ext.data.BelongsToAssociation.js +++ b/docs/output/Ext.data.BelongsToAssociation.js @@ -1,233 +1,293 @@ Ext.data.JsonP.Ext_data_BelongsToAssociation({ - "tagname": "class", - "name": "Ext.data.BelongsToAssociation", - "doc": "

Represents a many to one association with another model. The owner model is expected to have\na foreign key which references the primary key of the associated model:

\n\n\n\n\n
Ext.define('Category', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',   type: 'int'},\n        {name: 'name', type: 'string'}\n    ]\n});\n\nExt.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',          type: 'int'},\n        {name: 'category_id', type: 'int'},\n        {name: 'name',        type: 'string'}\n    ],\n    // we can use the belongsTo shortcut on the model to create a belongsTo association\n    belongsTo: {type: 'belongsTo', model: 'Category'}\n});\n
\n\n\n

In the example above we have created models for Products and Categories, and linked them together\nby saying that each Product belongs to a Category. This automatically links each Product to a Category\nbased on the Product's category_id, and provides new functions on the Product model:

\n\n\n\n\n

Generated getter function

\n\n\n\n\n

The first function that is added to the owner model is a getter function:

\n\n\n\n\n
var product = new Product({\n    id: 100,\n    category_id: 20,\n    name: 'Sneakers'\n});\n\nproduct.getCategory(function(category, operation) {\n    //do something with the category object\n    alert(category.get('id')); //alerts 20\n}, this);\n
\n\n\n\n\n

The getCategory function was created on the Product model when we defined the association. This uses the\nCategory's configured proxy to load the Category asynchronously, calling the provided\ncallback when it has loaded.

\n\n\n\n\n

The new getCategory function will also accept an object containing success, failure and callback properties\n- callback will always be called, success will only be called if the associated model was loaded successfully\nand failure will only be called if the associatied model could not be loaded:

\n\n\n\n\n
product.getCategory({\n    callback: function(category, operation) {}, //a function that will always be called\n    success : function(category, operation) {}, //a function that will only be called if the load succeeded\n    failure : function(category, operation) {}, //a function that will only be called if the load did not succeed\n    scope   : this //optionally pass in a scope object to execute the callbacks in\n});\n
\n\n\n\n\n

In each case above the callbacks are called with two arguments - the associated model instance and the\noperation object that was executed to load that instance. The Operation object is\nuseful when the instance could not be loaded.

\n\n\n\n\n

Generated setter function

\n\n\n\n\n

The second generated function sets the associated model instance - if only a single argument is passed to\nthe setter then the following two calls are identical:

\n\n\n\n\n
//this call\nproduct.setCategory(10);\n\n//is equivalent to this call:\nproduct.set('category_id', 10);\n
\n\n\n

If we pass in a second argument, the model will be automatically saved and the second argument passed to\nthe owner model's save method:

\n\n\n
product.setCategory(10, function(product, operation) {\n    //the product has been saved\n    alert(product.get('category_id')); //now alerts 10\n});\n\n//alternative syntax:\nproduct.setCategory(10, {\n    callback: function(product, operation), //a function that will always be called\n    success : function(product, operation), //a function that will only be called if the load succeeded\n    failure : function(product, operation), //a function that will only be called if the load did not succeed\n    scope   : this //optionally pass in a scope object to execute the callbacks in\n})\n
\n\n\n\n\n

Customisation

\n\n\n\n\n

Associations reflect on the models they are linking to automatically set up properties such as the\nprimaryKey and foreignKey. These can alternatively be specified:

\n\n\n\n\n
Ext.define('Product', {\n    fields: [...],\n\n    associations: [\n        {type: 'belongsTo', model: 'Category', primaryKey: 'unique_id', foreignKey: 'cat_id'}\n    ]\n});\n 
\n\n\n\n\n

Here we replaced the default primary key (defaults to 'id') and foreign key (calculated as 'category_id')\nwith our own settings. Usually this will not be needed.

\n\n", - "extends": "Ext.data.Association", - "mixins": [ - - ], - "alternateClassNames": [ + "allMixins": [ ], - "xtype": null, - "author": "Ed Spencer", + "deprecated": null, "docauthor": null, - "singleton": false, - "private": false, - "cfg": [ - { - "tagname": "cfg", - "name": "associatedModel", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The string name of the model that is being associated with. Required

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 124, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-cfg-associatedModel" - }, - { - "tagname": "cfg", - "name": "associationKey", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The name of the property in the data to read the association from.\nDefaults to the name of the associated model.

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 138, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-cfg-associationKey" - }, - { - "tagname": "cfg", - "name": "foreignKey", - "member": "Ext.data.BelongsToAssociation", - "type": "String", - "doc": "

The name of the foreign key on the owner model that links it to the associated\nmodel. Defaults to the lowercased name of the associated model plus \"_id\", e.g. an association with a\nmodel called Product would set up a product_id foreign key.

\n\n
Ext.define('Order', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'date'],\n    hasMany: 'Product'\n});\n\nExt.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'order_id'], // refers to the id of the order that this product belongs to\n    belongsTo: 'Group'\n});\nvar product = new Product({\n    id: 1,\n    name: 'Product 1',\n    order_id: 22\n}, 1);\nproduct.getOrder(); // Will make a call to the server asking for order_id 22\n\n
\n\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/BelongsToAssociation.js", - "linenr": 123, - "html_filename": "BelongsToAssociation.html", - "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-foreignKey", - "shortDoc": "The name of the foreign key on the owner model that links it to the associated\nmodel. Defaults to the lowercased name..." - }, - { - "tagname": "cfg", - "name": "getterName", - "member": "Ext.data.BelongsToAssociation", - "type": "String", - "doc": "

The name of the getter function that will be added to the local model's prototype.\nDefaults to 'get' + the name of the foreign model, e.g. getCategory

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/BelongsToAssociation.js", - "linenr": 149, - "html_filename": "BelongsToAssociation.html", - "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-getterName", - "shortDoc": "The name of the getter function that will be added to the local model's prototype.\nDefaults to 'get' + the name of th..." - }, - { - "tagname": "cfg", - "name": "ownerModel", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The string name of the model that owns the association. Required

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 120, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-cfg-ownerModel" - }, - { - "tagname": "cfg", - "name": "primaryKey", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The name of the primary key on the associated model. Defaults to 'id'.\nIn general this will be the Ext.data.Model.idProperty of the Model.

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 128, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-cfg-primaryKey", - "shortDoc": "The name of the primary key on the associated model. Defaults to 'id'.\nIn general this will be the Ext.data.Model.idP..." - }, - { - "tagname": "cfg", - "name": "reader", - "member": "Ext.data.Association", - "type": "Ext.data.reader.Reader", - "doc": "

A special reader to read associated data

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 134, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-cfg-reader" - }, - { - "tagname": "cfg", - "name": "setterName", - "member": "Ext.data.BelongsToAssociation", - "type": "String", - "doc": "

The name of the setter function that will be added to the local model's prototype.\nDefaults to 'set' + the name of the foreign model, e.g. setCategory

\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/BelongsToAssociation.js", - "linenr": 154, - "html_filename": "BelongsToAssociation.html", - "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-setterName", - "shortDoc": "The name of the setter function that will be added to the local model's prototype.\nDefaults to 'set' + the name of th..." - }, - { - "tagname": "cfg", - "name": "type", - "member": "Ext.data.BelongsToAssociation", - "type": "String", - "doc": "

The type configuration can be used when creating associations using a configuration object.\nUse 'belongsTo' to create a HasManyAssocation

\n\n
associations: [{\n    type: 'belongsTo',\n    model: 'User'\n}]\n
\n\n", - "private": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/BelongsToAssociation.js", - "linenr": 159, - "html_filename": "BelongsToAssociation.html", - "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-type", - "shortDoc": "The type configuration can be used when creating associations using a configuration object.\nUse 'belongsTo' to create..." - } - ], - "method": [ - { - "tagname": "method", - "name": "BelongsToAssociation", - "member": "Ext.data.Association", - "doc": "\n", - "params": [ - { + "members": { + "cfg": [ + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "Association.html#Ext-data-Association-cfg-associatedModel", + "shortDoc": "The string name of the model that is being associated with. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "associatedModel", + "owner": "Ext.data.Association", + "doc": "

The string name of the model that is being associated with. Required

\n", + "linenr": 122, + "html_filename": "Association.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "Association.html#Ext-data-Association-cfg-associationKey", + "shortDoc": "The name of the property in the data to read the association from. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "associationKey", + "owner": "Ext.data.Association", + "doc": "

The name of the property in the data to read the association from.\nDefaults to the name of the associated model.

\n", + "linenr": 136, + "html_filename": "Association.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-foreignKey", + "shortDoc": "The name of the foreign key on the owner model that links it to the associated\nmodel. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/BelongsToAssociation.js", + "private": false, + "name": "foreignKey", + "owner": "Ext.data.BelongsToAssociation", + "doc": "

The name of the foreign key on the owner model that links it to the associated\nmodel. Defaults to the lowercased name of the associated model plus \"_id\", e.g. an association with a\nmodel called Product would set up a product_id foreign key.

\n\n
Ext.define('Order', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'date'],\n    hasMany: 'Product'\n});\n\nExt.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'order_id'], // refers to the id of the order that this product belongs to\n    belongsTo: 'Group'\n});\nvar product = new Product({\n    id: 1,\n    name: 'Product 1',\n    order_id: 22\n}, 1);\nproduct.getOrder(); // Will make a call to the server asking for order_id 22\n\n
\n\n", + "linenr": 123, + "html_filename": "BelongsToAssociation.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-getterName", + "shortDoc": "The name of the getter function that will be added to the local model's prototype. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/BelongsToAssociation.js", + "private": false, + "name": "getterName", + "owner": "Ext.data.BelongsToAssociation", + "doc": "

The name of the getter function that will be added to the local model's prototype.\nDefaults to 'get' + the name of the foreign model, e.g. getCategory

\n", + "linenr": 149, + "html_filename": "BelongsToAssociation.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "Association.html#Ext-data-Association-cfg-ownerModel", + "shortDoc": "The string name of the model that owns the association. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "ownerModel", + "owner": "Ext.data.Association", + "doc": "

The string name of the model that owns the association. Required

\n", + "linenr": 118, + "html_filename": "Association.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "Association.html#Ext-data-Association-cfg-primaryKey", + "shortDoc": "The name of the primary key on the associated model. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "primaryKey", + "owner": "Ext.data.Association", + "doc": "

The name of the primary key on the associated model. Defaults to 'id'.\nIn general this will be the Ext.data.Model.idProperty of the Model.

\n", + "linenr": 126, + "html_filename": "Association.html" + }, + { + "type": "Ext.data.reader.Reader", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "Association.html#Ext-data-Association-cfg-reader", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "reader", + "owner": "Ext.data.Association", + "doc": "

A special reader to read associated data

\n", + "linenr": 132, + "html_filename": "Association.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-setterName", + "shortDoc": "The name of the setter function that will be added to the local model's prototype. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/BelongsToAssociation.js", + "private": false, + "name": "setterName", + "owner": "Ext.data.BelongsToAssociation", + "doc": "

The name of the setter function that will be added to the local model's prototype.\nDefaults to 'set' + the name of the foreign model, e.g. setCategory

\n", + "linenr": 154, + "html_filename": "BelongsToAssociation.html" + }, + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "cfg", + "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation-cfg-type", + "shortDoc": "The type configuration can be used when creating associations using a configuration object. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/BelongsToAssociation.js", + "private": false, + "name": "type", + "owner": "Ext.data.BelongsToAssociation", + "doc": "

The type configuration can be used when creating associations using a configuration object.\nUse 'belongsTo' to create a HasManyAssocation

\n\n
associations: [{\n    type: 'belongsTo',\n    model: 'User'\n}]\n
\n\n", + "linenr": 159, + "html_filename": "BelongsToAssociation.html" + } + ], + "method": [ + { + "deprecated": null, + "alias": null, + "href": "Association.html#Ext-data-Association-method-constructor", + "tagname": "method", + "protected": false, + "shortDoc": "Creates the Association object. ...", + "static": false, + "params": [ + { + "type": "Object", + "optional": true, + "doc": "

(optional) Config object.

\n", + "name": "config" + } + ], + "private": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "doc": "

Creates the Association object.

\n", + "owner": "Ext.data.Association", + "name": "BelongsToAssociation", + "html_filename": "Association.html", + "return": { "type": "Object", - "name": "config", - "doc": "

Optional config object

\n", - "optional": false - } - ], - "return": { - "type": "void", - "doc": "\n" + "doc": "\n" + }, + "linenr": 170 }, - "private": false, - "static": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 1, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-method-constructor", - "shortDoc": "\n" - }, - { - "tagname": "method", - "name": "getReader", - "member": "Ext.data.Association", - "doc": "

Get a specialized reader for reading associated data

\n", - "params": [ + { + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "method", + "href": "Association.html#Ext-data-Association-method-getReader", + "shortDoc": "Get a specialized reader for reading associated data ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "params": [ - ], - "return": { - "type": "Ext.data.reader.Reader", - "doc": "

The reader, null if not supplied

\n" + ], + "name": "getReader", + "owner": "Ext.data.Association", + "doc": "

Get a specialized reader for reading associated data

\n", + "linenr": 214, + "return": { + "type": "Ext.data.reader.Reader", + "doc": "

The reader, null if not supplied

\n" + }, + "html_filename": "Association.html" + } + ], + "property": [ + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "property", + "href": "Association.html#Ext-data-Association-property-associatedName", + "shortDoc": "The name of the model is on the other end of the association (e.g. ...", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "associatedName", + "owner": "Ext.data.Association", + "doc": "

The name of the model is on the other end of the association (e.g. if a User model hasMany Orders, this is 'Order')

\n", + "linenr": 202, + "html_filename": "Association.html" }, - "private": false, - "static": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 212, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-method-getReader", - "shortDoc": "

Get a specialized reader for reading associated data

\n" - } - ], - "property": [ - { - "tagname": "property", - "name": "associatedName", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The name of the model is on the other end of the association (e.g. if a User model hasMany Orders, this is 'Order')

\n", - "private": false, - "static": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 200, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-property-associatedName" - }, - { - "tagname": "property", - "name": "ownerName", - "member": "Ext.data.Association", - "type": "String", - "doc": "

The name of the model that 'owns' the association

\n", - "private": false, - "static": false, - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/Association.js", - "linenr": 194, - "html_filename": "Association.html", - "href": "Association.html#Ext-data-Association-property-ownerName" - } - ], - "event": [ + { + "type": "String", + "deprecated": null, + "alias": null, + "protected": false, + "tagname": "property", + "href": "Association.html#Ext-data-Association-property-ownerName", + "static": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/Association.js", + "private": false, + "name": "ownerName", + "owner": "Ext.data.Association", + "doc": "

The name of the model that 'owns' the association

\n", + "linenr": 196, + "html_filename": "Association.html" + } + ], + "cssVar": [ - ], - "filename": "/Users/nick/Projects/sencha/SDK/platform/src/data/BelongsToAssociation.js", - "linenr": 1, - "html_filename": "BelongsToAssociation.html", - "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation", - "cssVar": [ + ], + "cssMixin": [ - ], - "cssMixin": [ + ], + "event": [ - ], - "component": false, + ] + }, + "singleton": false, + "alias": null, "superclasses": [ "Ext.data.Association" ], + "protected": false, + "tagname": "class", + "mixins": [ + + ], + "href": "BelongsToAssociation.html#Ext-data-BelongsToAssociation", "subclasses": [ ], + "static": false, + "author": "Ed Spencer", + "component": false, + "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/BelongsToAssociation.js", + "private": false, + "alternateClassNames": [ + + ], + "name": "Ext.data.BelongsToAssociation", + "doc": "

Represents a many to one association with another model. The owner model is expected to have\na foreign key which references the primary key of the associated model:

\n\n\n\n\n
Ext.define('Category', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',   type: 'int'},\n        {name: 'name', type: 'string'}\n    ]\n});\n\nExt.define('Product', {\n    extend: 'Ext.data.Model',\n    fields: [\n        {name: 'id',          type: 'int'},\n        {name: 'category_id', type: 'int'},\n        {name: 'name',        type: 'string'}\n    ],\n    // we can use the belongsTo shortcut on the model to create a belongsTo association\n    belongsTo: {type: 'belongsTo', model: 'Category'}\n});\n
\n\n\n

In the example above we have created models for Products and Categories, and linked them together\nby saying that each Product belongs to a Category. This automatically links each Product to a Category\nbased on the Product's category_id, and provides new functions on the Product model:

\n\n\n\n\n

Generated getter function

\n\n\n\n\n

The first function that is added to the owner model is a getter function:

\n\n\n\n\n
var product = new Product({\n    id: 100,\n    category_id: 20,\n    name: 'Sneakers'\n});\n\nproduct.getCategory(function(category, operation) {\n    //do something with the category object\n    alert(category.get('id')); //alerts 20\n}, this);\n
\n\n\n\n\n

The getCategory function was created on the Product model when we defined the association. This uses the\nCategory's configured proxy to load the Category asynchronously, calling the provided\ncallback when it has loaded.

\n\n\n\n\n

The new getCategory function will also accept an object containing success, failure and callback properties\n- callback will always be called, success will only be called if the associated model was loaded successfully\nand failure will only be called if the associatied model could not be loaded:

\n\n\n\n\n
product.getCategory({\n    callback: function(category, operation) {}, //a function that will always be called\n    success : function(category, operation) {}, //a function that will only be called if the load succeeded\n    failure : function(category, operation) {}, //a function that will only be called if the load did not succeed\n    scope   : this //optionally pass in a scope object to execute the callbacks in\n});\n
\n\n\n\n\n

In each case above the callbacks are called with two arguments - the associated model instance and the\noperation object that was executed to load that instance. The Operation object is\nuseful when the instance could not be loaded.

\n\n\n\n\n

Generated setter function

\n\n\n\n\n

The second generated function sets the associated model instance - if only a single argument is passed to\nthe setter then the following two calls are identical:

\n\n\n\n\n
//this call\nproduct.setCategory(10);\n\n//is equivalent to this call:\nproduct.set('category_id', 10);\n
\n\n\n

If we pass in a second argument, the model will be automatically saved and the second argument passed to\nthe owner model's save method:

\n\n\n
product.setCategory(10, function(product, operation) {\n    //the product has been saved\n    alert(product.get('category_id')); //now alerts 10\n});\n\n//alternative syntax:\nproduct.setCategory(10, {\n    callback: function(product, operation), //a function that will always be called\n    success : function(product, operation), //a function that will only be called if the load succeeded\n    failure : function(product, operation), //a function that will only be called if the load did not succeed\n    scope   : this //optionally pass in a scope object to execute the callbacks in\n})\n
\n\n\n\n\n

Customisation

\n\n\n\n\n

Associations reflect on the models they are linking to automatically set up properties such as the\nprimaryKey and foreignKey. These can alternatively be specified:

\n\n\n\n\n
Ext.define('Product', {\n    fields: [...],\n\n    associations: [\n        {type: 'belongsTo', model: 'Category', primaryKey: 'unique_id', foreignKey: 'cat_id'}\n    ]\n});\n 
\n\n\n\n\n

Here we replaced the default primary key (defaults to 'id') and foreign key (calculated as 'category_id')\nwith our own settings. Usually this will not be needed.

\n\n", "mixedInto": [ ], - "allMixins": [ + "linenr": 1, + "xtypes": [ - ] + ], + "html_filename": "BelongsToAssociation.html", + "extends": "Ext.data.Association" }); \ No newline at end of file