PDA

View Full Version : [FIXED] Extending model perturbs associations (4.0.1)



christophe.geiser
25 May 2011, 12:34 AM
Hi
This is pretty weird, but extending a model seems to perturb associations of the extended Model....
This is pretty annoying when we use associatedModel is used to extract nested data in complex model associations.
Cheers
C.



Ext.define('Model',
{extend : 'Ext.data.Model',
hasMany : {
model : 'Model',
associationKey : 'items',
reader : {type : 'xml', selector : 'item', record : 'item', root : '.'}
},
idProperty : 'value',
fields : [ {name : 'label', mapping : 'label'}, {name : 'value'}]
});
console.info(Model.prototype.associations.items[0].associatedModel); // return a function -> correct

Ext.define('ModelExtend', {extend: 'Model'})
console.info(Model.prototype.associations.items[0].associatedModel); // return a the functionName

christophe.geiser
25 May 2011, 1:03 AM
I guess this should help (in Ext.data.Model.onClassExtended):


Ext.require(dependencies, function() {
Ext.ModelManager.registerType(name, cls);

for (i = 0, ln = associations.length; i < ln; ++i) {
association = Ext.apply({},associations[i]); // instead of association = associations[i]

Ext.apply(association, {
ownerModel: name,
associatedModel: association.model
})
...

christophe.geiser
8 Jun 2011, 2:00 AM
Hi
Can this change be included in 4.0.2 ?
Thanks
C.

christophe.geiser
9 Jun 2011, 10:51 PM
This is still a bug in 4.0.2.

christophe.geiser
26 Jun 2011, 11:31 PM
bump - still there in 4.0.2a

mitchellsimoens
27 Jun 2011, 6:51 AM
I guess this should help (in Ext.data.Model.onClassExtended):


Ext.require(dependencies, function() {
Ext.ModelManager.registerType(name, cls);

for (i = 0, ln = associations.length; i < ln; ++i) {
association = Ext.apply({},associations[i]); // instead of association = associations[i]

Ext.apply(association, {
ownerModel: name,
associatedModel: association.model
})
...

Have you tested this fix?

christophe.geiser
27 Jun 2011, 7:55 AM
Yep, this fix works for me.
Thanks for the answer,
C.

mitchellsimoens
27 Jun 2011, 8:00 AM
Yep, this fix works for me.
Thanks for the answer,
C.

OK... I will get it reported. Sorry it has taken a little bit to get to it but thank you for your patience.

christophe.geiser
8 Sep 2011, 4:37 AM
Bump - has the proposed fix been incorporated in recent code source ?
Thanks,
C.

christophe.geiser
21 Oct 2011, 12:00 AM
Answer: no, and this is still a bug under 4.0.7 (even with a proposed fix)...

christophe.geiser
15 Nov 2011, 11:35 PM
Bump - please consider this as a critical bug as it is not possible to extend models when associated...
This bug is still present in the 4.1 performance preview.
Thanks
C.

christophe.geiser
29 Nov 2011, 8:09 AM
Bump

mitchellsimoens
29 Nov 2011, 5:19 PM
We are prioritizing all the bugs. What we think is critical will be done in 4.1.0... other things will get deferred.

christophe.geiser
30 Nov 2011, 10:31 AM
Right, thank you for the answer.
Nevertheless, if the fact that not being able to extend models, is not considered as critical, then, I don't know what to say.

same problem here (http://www.sencha.com/forum/showthread.php?151693-Extending-Model-Not-Working).

Regards,
Christophe