ST 2.1 Store remove record fails with: Cannot call method 'hasOwnProperty' of null
Hi,
I'm trying to remove a record from a store of a hasMany association.
Code:
activeCheckIn.orders().remove(order);
Code:
associations: [{
type: 'hasMany',
model: 'MyApp.model.Order',
name: 'orders',
store: {
syncRemovedRecords: false
}
}]
This operation fails with a Cannot call method 'hasOwnProperty' of null in model.js Line 798.
Debugging revealed that during removing of the record in model.js destroy function modified is set to null.
Code:
destroy: function() {
var me = this;
me.notifyStores('afterErase', me);
if (me.getUseCache()) {
delete Ext.data.Model.cache[Ext.data.Model.generateCacheId(me)];
}
me.raw = me.stores = me.modified = null;
me.callParent(arguments);
},
Later in hasMany.js onRemoveRecords the foreign key is set to null
Code:
onRemoveRecords: function(store, records) {
var ln = records.length,
i, record;
for (i = 0; i < ln; i++) {
record = records[i];
record.set(this.getForeignKey(), null);
}
},
This fails in the Model.js set method in Line 798 because obviously modified is null.
Code:
if (modified.hasOwnProperty(fieldName)) {
A Workaround for this problem is to set destroyRemovedRecords: false