PDA

View Full Version : [CLOSED] Model 'id field leaks into subclasses



mankz
5 Jun 2014, 11:29 AM
In Ext 4 - this produces expected results. The 'bar' class has 1 and only one field. In Ext 5, it has 'id' too which was never added anywhere.

Ext.define('foo', {
extend : 'Ext.data.Model',
idProperty : null
})

Ext.define('bar', {
extend : 'foo',
idProperty : 'field1',

fields : ['field1']
})

evant
5 Jun 2014, 3:31 PM
This is the intended behaviour. Models always get an idField, it was a bug in 4 that they were never pushed on to the collection.

alumb
5 Sep 2014, 2:19 PM
The issue isn't that the model doesn't have an idProperty, the issue is that it ends up with fields for both the idProperty of the foo class and the idProperty of the bar class. This happens if foo is a base class that sets, for example the scheme, and all other models (including bar) extend this class.
This is particularly problematic when you use a proxy to save the bar class as it will POST {id:null, field1:ActualID}. The id field comes from the idProperty of the foo class and should not be present. Setting idProperty to null used to solve this issue, but doesn't seem to any longer.