PDA

View Full Version : [4.1 b2] associationKey property is ignored



abraxxa
14 Feb 2012, 9:56 AM
Below is an excerpt of my model and a grid using it, irrelevant code removed.
Nested data didn't show up in the grid below when using the Interface model.
After I've changed associationKey to name, which tells the reader where to find the related data and which defaults to name according to the docs, it started to work.



Ext.define("NAC.model.Device", {
extend:"NAC.data.Model",
associations:
[{
foreignKey:"id_device",
model:"NAC.model.Interface",
type:"hasMany",
associationKey:"rel_interfaces",
primaryKey:"fk_device"
}],
...
});

Ext.define("NAC.model.Interface", {
extend:"NAC.data.Model",
associations:
[{
foreignKey:"fk_device",
model:"NAC.model.Device",
type:"belongsTo",
associationKey:"rel_device",
primaryKey:"id_device"
}],
...
});

Ext.define('NAC.view.interface.Grid', {
alias: 'widget.interfacegrid',
extend: 'NAC.view.Grid',
title: 'Interfaces',
iconCls:'icon-interface',
store: 'Interfaces',
columns: [
{header:"Device", width:250, xtype:'templatecolumn',
tpl: '<a href="#Devices/view/{fk_device}"><tpl for="rel_device">{name}</tpl></a>'
}
]
});

abraxxa
14 Feb 2012, 10:05 AM
Actually it seems both name and associationKey is required to make it work.