3
私はExtJSをかなり新しくしており、少し苦労しています。複数のbelongsToで同じモデルタイプのExtJS 4モデルを作成するにはどうすればよいですか?
私は、同じモデル(母親と父親)といくつかの関係を持つ「人」モデルを持っています。
これらの関係にアクセスする方法はわかりません。
Ext.define('IwiDb.model.Person', {
extend: 'Ext.data.Model',
fields: [
'ID',
'Title',
'FirstName',
'MiddleNames',
'Surname',
//.. snip
'MotherID',
'FatherID',
],
associations: [{
type: 'belongsTo',
model: 'IwiDb.model.Person',
primaryKey: 'ID',
foreignKey: 'MotherID',
autoLoad: true,
name: 'Mother',
getterName: 'getMother',
},{
type: 'belongsTo',
model: 'IwiDb.model.Person',
primaryKey: 'ID',
foreignKey: 'FatherID',
autoLoad: true,
name: 'Father',
getterName: 'getFather',
}],
idProperty: 'ID',
proxy: {
type: 'rest',
url: 'api/v1.extjs/Person',
format: 'json',
reader: {
type: 'json',
root: 'items',
totalProperty: 'totalSize',
},
writer: {
type: 'json',
},
simpleSortMode: true,
}
});
EDIT:ここで私が持っているものだ私は私が近づいてるを考える、私は私が今持っているものにコードを更新しました。少なくとも私はperson.getMother()を実行し、関数を取得することができます。しかし、私はまだデータを取得できません。誰でも知っている?