View Full Version : Store with hasMany and grid

10 Jun 2013, 8:58 AM
I have a store with hasMany :

extend : 'Ext.data.Store',
model: 'MetExplore.model.DataMapping',
data:{rows:[{'object':'obj1','conditions':[{'condition':'obj1 cond1'},{'condition':'obj1 cond2'}]},
{'object':'obj2','conditions':[{'condition':'obj2 cond1'},{'condition':'obj2 cond2'}]}
autoLoad: true
Ext.define('MetExplore.model.DataMapping', {
extend : 'Ext.data.Model',
fields : [ {name : 'object'}], //objet du mapping = col1 du fichier de data
requires : ['MetExplore.model.Condition'],

hasMany : {
model : 'MetExplore.model.Condition',
name : 'conditions',
associationKey : 'conditions'

Ext.define('MetExplore.model.Condition', {
extend : 'Ext.data.Model',
fields : [ {
name : 'condition',
type : 'string'

i want to have a grid like this :

obj1 obj1_cond1 obj1_cond2
obj2 obj2_cond1 obj2_cond2

for this, i make a view :

alias: 'widget.gridData',
store: 'S_DataMapping',

// impossible to put it in V_GenericGrid
plugins:[Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2})],

text : 'Identifier OR Name OR Mass',
width : 200,
flex : 1,
sortable : true,
//filter: {type:'string'},
dataIndex: 'object',
editor: {
allowBlank: false}
text : 'Conditions',
columns: [
text: 'condition', /////////////////////////////////////////////////////////////////////
dataIndex: 'object.conditions[0]', // i don't know what i put here
editor: {allowBlank: false }/////////////////////////////////////////////////////////////////////
text: 'condition',
dataIndex: 'object.conditions[1]',
editor: {allowBlank: false}
editor: {
allowBlank: false


what it this necessary to put in dataIndex information in the view
Thank you

12 Jun 2013, 1:08 PM
You won't be able to link directly to the associated records' data using the mapping config. You can load nested data to the grid (without associations) and map through the nested data structure or you might be able to use a renderer and then return record.getMyAssocStore().get('requiredFieldForThatColumn').

The first option would be the one I'd pursue personally and just have my server structure the data nested for me on the first load - I think that will ultimately be the most performant option for you, but the associated data pull in the column renderer may be viable for you as well.