Results 1 to 8 of 8

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

    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
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    Try using store.remove(selectedRecord);
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Dec 2007
    Posts
    118
    Vote Rating
    12
      0  

    Default

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

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,615
    Vote Rating
    55
      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,615
    Vote Rating
    55
      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
      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
      0  

    Default

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

    M.

Posting Permissions

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