Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-9251 in a recent build.
  1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    118
    Vote Rating
    12
    corvonero will become famous soon enough

      0  

    Default on grid's record destroy, the selectionchange event is not fired

    on grid's record destroy, the selectionchange event is not fired


    ExtJS version 4.2

    in a gridpanel, if you do a

    selectedRecord.destroy();

    grid's selectionchange event is not fired.

    Workaround:

    do: grid.getSelectionModel( ).deselectAll();

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    873
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Try using store.remove(selectedRecord);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Dec 2007
    Posts
    118
    Vote Rating
    12
    corvonero will become famous soon enough

      0  

    Default


    That works, but then you need to have a proxy on the store. Am I wrong?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    873
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Not unless you have autoSync : true. If you use the destroy method on the record then it will try to send the request. Looking at the docs (http://docs.sencha.com/ext-js/4-2/#!...method-destroy) the description on the destroy method is:

    Destroys the model using the configured proxy.
    So if you use the destroy method it will try to send a request to the server for the destruction. store.remove(record) will just remove the record from the store's dataset and if autoSync is set to true (defaults to false) then it will try to send a request to the server.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


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

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Try this override:

    Code:
    Ext.override(Ext.data.Model, {
        destroy: function(options) {
            options = Ext.apply({
                records: [this],
                action : 'destroy'
            }, options);
    
            var me = this,
                isNotPhantom = me.phantom !== true,
                scope  = options.scope || me,
                stores,
                i = 0,
                storeCount,
                store,
                args,
                operation,
                callback;
    
            operation = new Ext.data.Operation(options);
    
            callback = function(operation) {
                args = [me, operation];
    
                // The stores property will be mutated, so clone it first
                stores = Ext.Array.clone(me.stores);
                if (operation.wasSuccessful()) {
                    for (storeCount = stores.length; i < storeCount; i++) {
                        store = stores[i];
    
                        // If the store has a remove (it's not a TreeStore), then
                        // remove this record from Store. Avoid Store handling anything by passing the "isMove" flag
                        if (store.remove) {
                            store.remove(me, true);
                        }
                        if (isNotPhantom) {
                            store.fireEvent('write', store, operation);
                            store.fireEvent('bulkremove', store, [me], [store.indexOf(me)], false);
                        }
                    }
                    me.clearListeners();
                    Ext.callback(options.success, scope, args);
                } else {
                    Ext.callback(options.failure, scope, args);
                }
                Ext.callback(options.callback, scope, args);
            };
    
            // Not a phantom, then we must perform this operation on the remote datasource.
            // Record will be removed from the store in the callback upon a success response
            if (isNotPhantom) {
                me.getProxy().destroy(operation, callback, me);
            }
            // If it's a phantom, then call the callback directly with a dummy successful ResultSet
            else {
                operation.complete = operation.success = true;
                operation.resultSet = me.getProxy().reader.nullResultSet;
                callback(operation);
            }
            return me;
        }
    });

  7. #7
    Sencha User
    Join Date
    Dec 2007
    Posts
    118
    Vote Rating
    12
    corvonero will become famous soon enough

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Not unless you have autoSync : true. ...
    Yep, I had autoSync on ...

    M.

  8. #8
    Sencha User
    Join Date
    Dec 2007
    Posts
    118
    Vote Rating
    12
    corvonero will become famous soon enough

      0  

    Default


    Quote Originally Posted by Animal View Post
    Try this override:
    Works fine, thanks.

    M.

Thread Participants: 2