PDA

View Full Version : Why is Model.getAssociatedData() empty



besogon
4 Dec 2019, 11:58 PM
I defined 2 models.



Ext.define('EventType', {
extend: 'Ext.data.Model',


idProperty: 'eventTypeId',


fields: [
{name: 'eventTypeId'}
]
});

Ext.define('Event', {
extend: 'Ext.data.Model',


idProperty: 'eventId',


fields: [
{name: 'eventId'},
{
name: 'eventTypeId',
type: 'string',
reference: {
type: 'EventType',
role: 'EventType',
association: 'EventsByType',
inverse: 'events'
}
},
]
});


Then I filled store 'EventType' with data:

[ {eventTypeId: 'A'},
{eventTypeId: 'B'},
{eventTypeId: 'C'}
]
and store 'Events'


[
{eventId:1, eventTypeId: 'A'},
{eventId:2, eventTypeId: 'A'},
{eventId:3,eventTypeId: 'C'}
]

Here is the example
https://fiddle.sencha.com/#view/editor&fiddle/31gm (https://fiddle.sencha.com/#view/editor&fiddle/31gm)

Result:
Model.getAssociatedData() => empty object
Model.getEventType() => correct Model

So.. the question: why?? Is it a bug or intended behavior? :-/
If this is not a bug then when getAssociatedData() should not be empty?