그래서 Sencha ExtJs 4.1 Associations을 사용하는 데 문제가 있습니다.Sencha ExtJS 연관 POST가 잘못 되었습니까?
{
"postTemplate": 1,
"id": 0,
"name": "foo"
}
: 문제는 내가 이런 POST를 얻고 있다는 것입니다
Ext.define('Tpl.store.Users', {
extend: 'Ext.data.Store',
model: 'Tpl.model.User',
autoLoad: true,
proxy: {
type: 'rest',
url: '../users',
reader: {
type: 'json',
root: ''
},
writer: {
type: 'json'
}
}
});
Ext.define('Tpl.store.PostTemplate', {
extend: 'Ext.data.Store',
model: 'Tpl.model.PostTemplate',
autoLoad: true,
proxy: {
type: 'rest',
//appendId: true,
url: '../postTemplates/',
reader: {
type: 'json',
root: ''
},
writer: {
type: 'json'
}
}
});
모델
Ext.define('Tpl.model.User', {
extend: 'Ext.data.Model',
requires: ['Tpl.model.PostTemplate'],
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'postTemplate', type: 'int' }
],
associations: [
{ type: 'belongsTo', name: 'postTemplate', model:'Tpl.model.PostTemplate', associationKey: 'postTemplate', primaryKey: 'id', foreignKey: 'postTemplate' }
]
});
and
Ext.define('Tpl.model.PostTemplate', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'blah', type: 'string' }
],
associations: [
{ type: 'hasMany', model: 'Tpl.model.User' }
]
});
상점 :
내가 좋아하는 뭔가를
는하지만이 같은 POST 필요
이{
"postTemplate": {
"id": 1,
"blah": "foo"
},
"id": 0,
"name": "bar"
}
또한, "setPostTemplate"와 같은 평가자 기능이 존재하지 않습니다 나는이 자동으로 생성한다고 생각합니다.
이미 같은 뭔가 시도 "record.data.postTemplate = (...)"하지만 내가 execption을 던지는 무한 루프 ...
누군가가 조언을 주실 수 있어요? 또한, 당신이 대답을 위해 유용 할 수있는 다른 것을 필요로한다면 저에게 알려주십시오.
감사합니다.
대단히 감사합니다. @dbrin !!! –