You found a bug! We've classified it as
EXTJS-15195
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Association just ignored if model class not found, no warning, even in debug build
I know over the years with just the people I have worked with, we lost hours for that issue. It's insane I didn't log that bug before.
Code below work perfectly, but if I remove the requires on Nextt.model.Option, then it will still load data, without any warning, even with the most 'debug' build of ext js, but will have no 'recollection' that we have declared association 'options'. Will show and behave like the following code is missing:
Code:
{
type : 'hasMany',
model : 'Nextt.model.Option',
name : 'options',
associationKey : 'transactionHeader.options'
}
Remove this, break silently the association:
Code:
requires: ['Nextt.model.Option']
Code:
Ext.define('Nextt.model.Transaction', {
extend : 'Ext.data.Model',
requires: ['Nextt.model.Option'],
fields : [ ],
associations : [ {
type : 'hasMany',
model : 'Nextt.model.Interval',
associationKey : 'intervals',
name : 'intervals',
storeConfig : {
xclass : 'Nextt.store.IntervalStore'
}
}, {
type : 'hasMany',
model : 'Nextt.model.Option',
name : 'options',
associationKey : 'transactionHeader.options'
} ]
});
-
The problem is an issue of timing. By their nature, one class will always have to be defined before the other, so it's not possible at definition time to say "the class is missing". Pushing that out further, you could be using dynamic loading, so the class could come along at any time.
Twitter - @evantrimboli
Former Sencha framework engineer, available for consulting.
As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.
-
I do have warning in console when extjs proactively load a class at the last minute when using dynamic loading. I also have error, when a class is asked for but not loaded and not able to be loaded. This case is very exceptional, it fail silently. I understand if the association structure support cycle reference, at the initialization you cannot really give warning or error if a class is still not findable. But later on, like when reading/write association, that class is expected to be used, and not found, at that time an error or warning should occur.