View Full Version : [CLOSED] Using child data in grids

18 Apr 2011, 1:31 AM
I have not been able figure out how child data can be referenced using a "dataIndex" in grids.

It may be impractical to expect that you could reference the children in a hasMany relationship, but what about data associated with "belongsTo" ?

For example, if table user exists as so:


and person exists as:


When referencing user, shouldnt you be able to provide an index of:

If this is not currently possible, and it is added, please do not forget to consider relationships from one model to itself, such as "group.parent_group_id" (a loopback of sorts), and multiple references to the same table, such as "group_relationship.parent_group_id" and "group_relationship.child_group_id".

24 Apr 2011, 9:56 PM
A short example:

Ext.define('Person', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
hasMany: 'Ticket'

Ext.define('Ticket', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],
belongsTo: 'Person'


Ext.create('Ext.grid.Panel', {
width: 400,
height: 400,
renderTo: document.body,
store: {
model: 'Person',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data.json'
columns: [{
header: 'Foo',
xtype: 'templatecolumn',
dataIndex: 'name',
tpl: '{name}<br /><tpl for="tickets"><div>{id} - {name}</div></tpl>'

"id": 1,
"name": "User 1",
"tickets": [{
"id": 1,
"name": "A is broken"
"id": 2,
"name": "B is broken"
"id": 2,
"name": "User 2",
"tickets": [{
"id": 3,
"name": "X is broken"
"id": 4,
"name": "Y is broken"

You could also use a column renderer to grab the data, the record is the 3rd parameter.

5 Jul 2011, 5:40 AM
We need to group a grid by such a field of a belongsTo child.

The grid grouping expects a field in the model, but "templatecolumn" columns and column renderers are on column level of a grid, but not on model level.

How can we accomplish this, maybe even with calculated child model fields (using "convert" property)?