当我想创建多对多关联时,我遇到了一些问题。因为它不知道。我尝试以这种方式建立关系。但我不确定。任何人都可以帮助我吗?我该怎么做?。这是我的代码
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'}]
});
第二个模型在这里
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'}]
});