I have two Models. Master -
Ext.define('App.model.Master', {
extend : 'Ext.data.Model'
,fields : [
{ name : 'master_name', type : 'string' },
{ name : 'id', type : 'int'}
]
,proxy : {
type : 'rest',
url : '/master',
reader : {
type : 'json',
root : 'masters'
}
}
,associations : [{
type : 'hasMany'
id : 'id',
foreignKey : 'master_id',
associationKey : 'details',
name : 'details',
model : 'App.model.Detail',
}]
});
and Detail -
Ext.define('App.model.Detail', {
extend : 'Ext.data.Model'
fields : [
{ name : 'detail_name', type : 'string' },
{ name : 'id', type : 'int' },
{name : 'master_id', type : 'string'}
]
});
My problem is, when I add a new Master record, there is a Detail that is added automatically in the Server. And the response that I get is -
{
success : true,
masters : {
master_name : 'aaa',
id : 1,
details : [
{
detail_name : 'bbb',
id : 11,
master_id : 1
}
]
}
}
Despite all my efforts, I'm not able to read the 'detail', once the response is added into the Master Store. I would think that the 'record.details()' would give me the one record that came back on adding of the Master, but I get nothing.
However, if I reload the store, I'm able to get the data correctly.
I need to be able to read the nested response on Store.add() as well.
Any help is much appreciated.
masters, but it does not seem to be part of the JSON that the server returns. Have you simply omitted that? - Izhaki