我有一系列人,每个人都有一系列联系人。数据采用json格式:
[
{
"id": 7900,
"position": "Tillitsvalgt",
"person": {
"id": 1000001,
"lastName": "Andrushko",
"contacts": [
{
"id": 1000001,
"personId": 1000001,
"type": {
"id": 5,
"name": "Mobile phone"
},
"value": "25417"
},
{
"id": 1000002,
"personId": 1000001,
"type": {
"id": 35,
"name": "Mobile phone"
},
"value": "945417"
}
]
}
},
{
"id": 7900,
"position": "Tillitsvalgt",
"person": {
"id": 1000001,
"lastName": "Andrushko",
"contacts": [
{
"id": 1000001,
"personId": 1000001,
"type": {
"id": 5,
"name": "Mobile phone"
},
"value": "25417"
},
{
"id": 1000002,
"personId": 1000001,
"type": {
"id": 35,
"name": "Mobile phone"
},
"value": "945417"
}
]
}
}
]
我想显示两个网格,第一个显示人物,第二个显示选定人物的联系人。我创建了两个模型:
Ext.define('Person', {
extend: 'Ext.data.Model',
fields: [
{
mapping: 'person.lastName',
name: 'lastName'
}
],
hasMany: [
{
associationKey: 'person.contacts',
model: 'Contact',
name: 'contacts'
}
],
proxy: {
type: 'ajax',
url: 'MemberServlet?operation=get',
reader: {
type: 'json'
}
}
});
和联系人模型:
Ext.define('Contact', {
extend: 'Ext.data.Model',
fields: [
{
mapping: 'type.name',
name: 'type'
},
{
name: 'value'
}
],
belongsTo: {
model: 'Person'
}
});
在这样的配置中,我的第二个网格显示所有人的联系人,我希望它仅显示给选定的人。我该怎么办?