Results 1 to 2 of 2

Thread: ST 2.1 Store remove record fails with: Cannot call method 'hasOwnProperty' of null

Hybrid View

Previous Post Previous Post   Next Post Next Post
    Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-3720 in a recent build.
  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    88
    Vote Rating
    4
      0  

    Default 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

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Vote Rating
    1296
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •