I have this store which has Data in it:
Code:
Ext.define('app.store.OrderStore', { extend: 'Ext.data.Store',
config: {
model: 'app.model.Order',
storeId: 'OrderStore',
autoLoad: true,
data : [
{
orderId : '00410',
name : 'Piston',
productionQuantity : '4',
materials : [
{
materialId : 'ALU.BAR.10X70',
description : 'Aluminium bar 10 x 70',
quantityPP : '70mm',
totalQuantity : '0.4m'
}],
operations : [
{
operationId : 'SAW',
lineNr : '10',
description : 'Sawing big',
started : false
}]
}
],
}
});
And this is the Order model which has two hasMany item(Material and Operation):
Code:
Ext.define('app.model.Order', { extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields: [
{ name: 'orderId', type: 'string'},
{ name: 'name', type: 'string'},
{ name: 'productionQuantity', type: 'string'},
],
hasMany: [
{
associationKey: 'operations',
model: 'app.model.Operation',
name: 'operation'
},
{
associationKey: 'materials',
model: 'app.model.Material',
name: 'material'
}
]
}
});
For some reason when the Store is loaded it only loads in the materials into the material array. The operation array is always empty. When i switch the two hasMany items, it loads in the operations but not the materials. So it only seems to be loading in the properties of one the two.
Here are the Material and Operation models:
Code:
Ext.define('app.model.Material', { extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields: [
{ name: 'materialId', type: 'string'},
{ name: 'description', type: 'string'},
{ name: 'quantityPP', type: 'string'},
{ name: 'totalQuantity',type: 'string'},
{ name: 'orderId', type: 'string'}
],
belongsTo: [
{
model: 'app.model.Order',
foreignKey: 'orderId'
}
]
}
});
Code:
Ext.define('app.model.Operation', { extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields: [
{ name: 'operationId', type: 'string'},
{ name: 'lineNr', type: 'int'},
{ name: 'description', type: 'string'},
{ name: 'started', type: 'boolean'},
{ name: 'orderId', type: 'string'}
],
belongsTo: [
{
model: 'app.model.Order',
foreignKey: 'orderId'
}
]
}
});
Edit: Ok after some testing it doesn't seem to switch between the two. It's only loading in Operations. And it seems that the first item of the operation array contains an Order object which is it's parent. Why is this?