Extjs 4.1 powiązanie modelu wiele-do-wielu
napotykam pewien problem, gdy chcę utworzyć stowarzyszenie wiele-do-wielu. ponieważ nie wie. staram się tworzyć relacje w ten sposób. ale nie jestem pewien. każdy mężczyzna może mi pomóc? jak mogę to zrobić?. oto mój kod
Ext.define('Ext4Example.model.Category', {
extend : 'Ext.data.Model',
alias : 'widget.categoryModel',
idProperty: 'id',
fields: [
{name:'id', mapping:'id', type:'int'},
{name:'name', mapping:'name', type:'string'}
],
proxy: {
type: 'ajax',
noCache: false,
api: {
create : '${createLink(controller:'category', action: 'create')}',
read : '${createLink(controller:'category', action: 'read')}',
update : '${createLink(controller:'category', action: 'update')}',
destroy : '${createLink(controller:'category', action: 'destroy')}'
},
actionMethods: {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE'
},
reader: {
type : 'json',
root : 'data',
totalProperty : 'total',
successProperty : 'success',
messageProperty : 'message',
implicitIncludes: true
},
writer: {
type : 'json',
root : 'data',
writeAllFields: true
},
simpleSortMode: true
},
hasMany: [{model: 'Manufacturer', name: 'manufacturers'}]
});
Drugi model jest tutaj
Ext.define('Ext4Example.model.Manufacturer', {
extend : 'Ext.data.Model',
alias : 'widget.manufacturerModel',
idProperty: 'id',
fields: [
{name:'id', mapping:'id', type:'int'},
{name:'name', mapping:'name', type:'string'}
],
proxy: {
type: 'ajax',
noCache: false,
api: {
create : '${createLink(controller:'manufacturer', action: 'create')}',
read : '${createLink(controller:'manufacturer', action: 'read')}',
update : '${createLink(controller:'manufacturer', action: 'update')}',
destroy : '${createLink(controller:'manufacturer', action: 'destroy')}'
},
actionMethods: {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE'
},
reader: {
type : 'json',
root : 'data',
totalProperty : 'total',
successProperty : 'success',
messageProperty : 'message',
implicitIncludes: true
},
writer: {
type : 'json',
root : 'data',
writeAllFields: true
},
simpleSortMode: true
},
hasMany: [{model: 'Category', name: 'categories'}]
});