Answer the question
In order to leave comments, you need to log in
Ext.JS 4+ How to display related data in Ext.grid.Panel?
Hey! Faced the following problem.
There are 2 data models:
Ext.define('ParserGoods.model.GroupList', {
extend: 'Ext.data.Model',
fields: [
'group_id', 'infoblock_id', 'id', 'group_name',
],
associations: [
{type: 'belongsTo', model: 'ParserGoods.model.InfobloksList', name: 'infoblock'}
],
proxy: {
type: 'ajax',
url: '/group/getlist',
reader: {
root: 'data',
totalProperty: 'totalCount',
type: 'json'
},
simpleSortMode: true
}
});
Ext.define('ParserGoods.store.GroupListStore', {
extend: 'Ext.data.Store',
model: 'ParserGoods.model.GroupList',
storeId: 'GroupListStore',
remoteSort: true,
pageSize: 20,
sorters: [{
property: 'group_name',
direction: 'DESC'
}],
autoLoad: true
});
{
"infoblock": {
"infoblock_name":"Комплектующие",
"infoblock_id":"1",
"insert_time":"2014-04-03 13:25:49",
"id":"27"
},
"group_name":"Сетевые адаптеры",
"group_id":"60c83bfa",
"infoblock_id":"1",
"id":"153"
},{
"infoblock": {
"infoblock_name":"Комплектующие",
"infoblock_id":"1",
"insert_time":"2014-04-03 13:25:49",
"id":"27"
},
"group_name":"Сетевые адаптеры",
"group_id":"60c83bfa",
"infoblock_id":"1",
"id":"153"
}
{
text : 'Id группы',
flex: 1,
dataIndex: 'group_id',
filter: {
type: 'string'
}
},{
text : 'Название группы',
flex: 1,
dataIndex: 'group_name',
filter: {
type: 'string'
}
},{
text : 'infoblock_name',
flex: 1,
dataIndex: 'infoblock.infoblock_name',
filter: {
type: 'string'
}
}
Answer the question
In order to leave comments, you need to log in
try
Ext.define('ParserGoods.model.GroupList', {
extend: 'Ext.data.Model',
fields: [
{
name: 'group_id',
mapping: 'infoblock.group_id'
},
{
name: 'group_id',
mapping: 'infoblock.group_id'
},
{
name: 'group_name',
mapping: 'infoblock.group_name'
}
],
associations: [
{type: 'belongsTo', model: 'ParserGoods.model.InfobloksList', name: 'infoblock'}
],
proxy: {
type: 'ajax',
url: '/group/getlist',
reader: {
root: 'data',
totalProperty: 'totalCount',
type: 'json'
},
simpleSortMode: true
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question