Sencha Documentation

Associations enable you to express relationships between different Models. Let's say we're writing an ecommerce system where Users can make Orders - there's a relationship between these Models that we can express like this:

Ext.regModel('User', {
    fields: ['id', 'name', 'email'],

    hasMany: {model: 'Order', name: 'orders'}
});

Ext.regModel('Order', {
    fields: ['id', 'user_id', 'status', 'price'],

    belongsTo: 'User'
});

We've set up two models - User and Order - and told them about each other. You can set up as many associations on each Model as you need using the two default types - hasMany and belongsTo. There's much more detail on the usage of each of those inside their documentation pages. If you're not familiar with Models already, there is plenty on those too.

Further Reading

Config Options

 
The string name of the model that is being associated with. Required
The string name of the model that is being associated with. Required
 
ownerModel : String
The string name of the model that owns the association. Required
The string name of the model that owns the association. Required
 
primaryKey : String
The name of the primary key on the associated model. Defaults to 'id'
The name of the primary key on the associated model. Defaults to 'id'

Properties

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