HasManyConfig Class

Namespace: Ext.data.association

Base Types

System.Object

Constructors

Name Description
HasManyConfig()

Properties

Name Description
autoLoad True to automatically load the related store from a remote source when instantiated. Defaults to false.
filterProperty Optionally overrides the default filter that is set up on the associated Store. If this is not set, a filter is automatically created which filters the association based on the configured {@link #foreignKey}. See intro docs for more details. Defaults to undefined
foreignKey The name of the foreign key on the associated model that links it to the owner model. Defaults to the lowercased name of the owner model plus "_id", e.g. an association with a where a model called Group hasMany Users would create 'group_id' as the foreign key. When the remote store is loaded, the store is automatically filtered so that only records with a matching foreign key are included in the resulting child store. This can be overridden by specifying the {@link #filterProperty}.
  
Ext.define('Group', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
hasMany: 'User'
});
Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['id', 'name', 'group_id'], // refers to the id of the group that this user belongs to
belongsTo: 'Group'
});
            
name The name of the function to create on the owner model to retrieve the child store. If not specified, the pluralized name of the child model is used.
  
// This will create a users() method on any Group model instance
Ext.define('Group', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
hasMany: 'User'
});
var group = new Group();
console.log(group.users());
// The method to retrieve the users will now be getUserList
Ext.define('Group', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
hasMany: {model: 'User', name: 'getUserList'}
});
var group = new Group();
console.log(group.getUserList());
            
storeConfig Optional configuration object that will be passed to the generated Store. Defaults to undefined.
© Copyright 2005-2011 SharpKit. All rights reserved.