PDA

View Full Version : Model.getAssociatedData does not work BUG??



besogon
26 Nov 2019, 10:29 PM
Here is the code.



Ext.application({
name : 'Fiddle',


launch : function() {
var session = new Ext.data.Session();
Ext.define('EventType', {
extend: 'Ext.data.Model',


idProperty: 'eventTypeId',


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


Ext.create('Ext.data.Store', {
session: session,
model: 'EventType',
data : [
{eventTypeId: 'A'},
{eventTypeId: 'B'},
{eventTypeId: 'C'}
]
});


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'
}
},
]
});


var s= Ext.create('Ext.data.Store', {
session: session,
model: 'Event',
data : [
{eventId:1, eventTypeId: 'A'},
{eventId:2, eventTypeId: 'A'},
{eventId:3,eventTypeId: 'C'}
]
});


var m = s.getAt(0);


console.log(m.getAssociatedData(), 'EMPTY');
console.log(m.getEventType(), 'EXISTS');
}
});



https://fiddle.sencha.com/#view/editor&fiddle/31gm (https://fiddle.sencha.com/#view/editor&fiddle/31gm)

Models has links but no associated data.