According to the Sencha documentation:
http://docs.sencha.com/extjs/6.2.1/classic/Ext.data.schema.Association.html#ext-data-schema-association_association-concepts
In this case the properties of the reference should be the following:
- type: the name of the parent-Model
- inverse: the name of the function, which should return the sub-Store (this is the name, which you should reference to, in the widget store binding)
Changes in the orderModel:
var orderMDL = Ext.define('orderModel', {
extend: 'Ext.data.Model',
fields: [
// Declare an association with Company.
// Each Company record will be decorated with
// an "orders" method which yields a store
// containing associated orders.
{
name: 'companyId',
reference: {
type:'companyModel',
inverse:'orders'
}
}, {
name: 'productCode'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'date',
type: 'date',
dateFormat: 'Y-m-d'
}, {
name: 'shipped',
type: 'boolean'
}],
proxy: {
type: 'memory',
data: ordersListJSONArray
}});
Changes in the widget:
widget: {
xtype: 'grid',
autoLoad: true,
bind: {
store: '{record.orders}',
title: 'Orders for {record.name}'
},
columns: [{
text: 'Order Id',
dataIndex: 'id',
width: 75
}, {
text: 'Procuct code',
dataIndex: 'productCode',
width: 265
}, {
text: 'Quantity',
dataIndex: 'quantity',
width: 100,
align: 'right'
}, {
format: 'Y-m-d',
width: 120,
text: 'Date',
dataIndex: 'date'
}, {
text: 'Shipped',
dataIndex: 'shipped',
width: 75
}]
}