我有一个员工最喜欢的关系,我在模型中使用hasMany / belongsTo语义映射。在我的商店中,我只是设置根并指向根数组,但我没有看到模型的收藏夹部分被填充。有什么想法吗?
我的人物模型:
Ext.define('People.model.Employee', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'cn'}
],
hasMany: { model: 'Favorite', name: 'favorites' }
}});
收藏夹模型:
Ext.define('People.model.Favorite', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'uid'},
{ name: 'fullName'}
],
belongsTo: 'Employee'
}});
商店:
Ext.define('People.store.Favorites', {
extend: 'Ext.data.Store',
requires: [
'People.model.Employee',
'People.model.Favorite'
],
config: {
autoLoad: false,
model: 'People.model.Employee',
storeId: 'Favorites',
proxy: {
type: 'jsonp',
url: People.app.favSearchUrl,
reader: {
type: 'json',
idProperty: 'cn',
rootProperty: 'records'
}
}
}});
我正在尝试使用的JSON如下:
{
"records": [
{
"_id": "5106f97bdcb713b818d7f1f1",
"cn": "lsacco",
"favorites": [
{
"fullName": "Friend One",
"uid": "friend1"
},
{
"fullName": "Friend Two",
"uid": "friend2"
}
]
}
]
}