Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Location
    Delft - The Netherlands
    Posts
    28
    Vote Rating
    3
    bas_tzx is on a distinguished road

      0  

    Default [FIXED-EXTJSIV-1818][4.0.0] record.destroy() callbacks not executed

    [FIXED-EXTJSIV-1818][4.0.0] record.destroy() callbacks not executed


    I am deleting a node from a tree and I want to use the callbacks to see whether the serverside action has been successful.

    Sadly, the destroy method doesn't seem to work. As a workaround I can call the doRequest method on the proxy.


    Code:
    var store = this.getStructuresStore(), //Ext.data.TreeStore
          record = tree.getView().getSelectedRecords()[0];
    
    // Callbacks not executed
    record.destroy({
        failure: function () {
            console.log('destroy failure!');
        },
        success: function () {
            console.log('destroy success!');
        },
        callback: function () {
            console.log('destroy callback!');
        }
    });
    
    // This works
    var operation = new Ext.data.Operation({
        action: 'destroy',
        id: record.getId()
    });
    
    store.getProxy().doRequest(operation, function () {
        console.log('request callback');
    });

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Can't reproduce this:

    Code:
    Ext.define('Item', {
        extend: 'Ext.data.Model',
        fields: ['id', 'foo'],
        proxy: {
            type: 'ajax',
            url: 'data.json'
        }
    });
    
    Ext.onReady(function() {
        
        var rec = new Item({
            id: 1,
            foo: 'bar'
        }, 1);
        
        rec.destroy({
            success: function(){
                console.log('success');
            },
            callback: function(){
                console.log('callback');
            },
            failure: function(){
                console.log('failure');
            }
        });
        
    });
    Server returns:
    Code:
    {"success": true}
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Location
    Delft - The Netherlands
    Posts
    28
    Vote Rating
    3
    bas_tzx is on a distinguished road

      0  

    Default


    To be more specific:

    The Ext.data.Model.destroy() method works, it performs the ajax request, but the succes/failure callbacks are not executed.

    If I use record.save() or the Ext.data.proxy.Rest.doRequest() everything works fine.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    As I said above, I can't reproduce it, the callbacks fire just fine for me.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    1
    Vote Rating
    0
    haorenpingan030 is on a distinguished road

      0  

    Default callbacks are not working for some unknown reason.

    callbacks are not working for some unknown reason.


    //I define a Flow model as follows(Using some rest):

    Ext.define('Flow', {
    extend : 'Ext.data.Model',
    fields : [ {
    name : 'id',
    type : 'int'
    }, {
    name : 'name',
    type : 'string'
    }, {
    name : 'owner',
    type : 'string'
    }, {
    name : 'ctime',
    type : 'string'
    } ],
    proxy : {
    type : 'rest',
    url : '/flow',
    reader : 'json'
    }
    });

    //selModel is a instance of Flow. It can be destroyed, but the callbacks(success, failure, callback) are not be called.

    selModel.destroy({
    success : function() {
    console.log('success?');
    },
    failure : function() {
    console.log('fail?');
    },
    callback : function(record, operation) {
    console.log('callback');
    }
    });

    //Enjoy the question!

  6. #6
    Sencha User
    Join Date
    Mar 2010
    Location
    Delft - The Netherlands
    Posts
    28
    Vote Rating
    3
    bas_tzx is on a distinguished road

      0  

    Default New example code

    New example code


    The following code renders a treePanel with a treeStore and an ajax proxy. I've put 2 buttons in the toolbar which both select a node and then destroy the selected record. The first button calls the destroy method on the record and these callbacks do not work (the request is made twice, so that's also a bit strange). The second button uses the proxy doRequest method and this callback works.

    Hopefully this code will give a better explaination (and will be probably show that I am doing something stupid )

    PHP Code:
    var store Ext.create('Ext.data.TreeStore', {
        
    root: {
            
    expandedtrue,
            
    text"root",
            
    children: [{
                    
    id1,
                    
    text"Node 1.1",
                    
    leaftrue
                
    },{
                    
    id2,
                    
    text"Node 1.2",
                    
    leaftrue
                
    },{
                    
    id3,
                    
    text"Node 1.3",
                    
    leaftrue
                
    },{
                    
    id4,
                    
    text"Node 1.4",
                    
    leaftrue
                
    },{
                    
    id5,
                    
    text"Node 1.5",
                    
    leaftrue
                
    }]
        },
        
    proxy: {
            
    type'ajax',
            
    url'delete.json' // Returns { "success" : true }
        
    }
    });


    Ext.onReady(function () {

        var 
    tree Ext.create('Ext.tree.Panel', {
            
    title'Model (record) destroy test',
            
    width300,
            
    height400,
            
    storestore,
            
    renderToExt.getBody(),
            
    tbar: [{
                
    xtype'button',
                
    text'record.destroy',
                
    handler: function () {
                    var 
    record,
                          
    selModel tree.getView().getSelectionModel();

                    
    // Select 2nd record
                    
    selModel.select(1);

                    
    // Get record
                    
    record selModel.getSelection()[0];

                    
    console.log('record'record);

                    
    // Callbacks not executed
                    
    record.destroy({
                        
    failure: function () {
                            
    console.log('destroy failure!');
                        },
                        
    success: function () {
                            
    console.log('destroy success!');
                        },
                        
    callback: function () {
                            
    console.log('destroy callback!');
                        }
                    });
                }
            }, {
                
    xtype'button',
                
    text'proxy.doRequest',
                
    handler: function () {
                    var 
    record,
                          
    operation,
                          
    selModel tree.getView().getSelectionModel();

                    
    // Select 2nd record
                    
    selModel.select(1);

                    
    // Get record
                    
    record selModel.getSelection()[0];

                    
    console.log('record'record);

                    
    operation = new Ext.data.Operation({
                        
    action'destroy',
                        
    idrecord.getId()
                    });

                    
    // This callback works
                    
    tree.getStore().getProxy().doRequest(operation, function () {
                        
    console.log('doRequest callback');
                    });

                }
            }]
        });

    }); 

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,050
    Vote Rating
    657
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Ok I see, it's something specifically affecting models decorated with NodeInterface. This should be resolved in the next release.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  8. #8
    Sencha User
    Join Date
    Mar 2010
    Location
    Delft - The Netherlands
    Posts
    28
    Vote Rating
    3
    bas_tzx is on a distinguished road

      0  

    Red face


    OK, thanks!

  9. #9
    Sencha User
    Join Date
    Jul 2009
    Location
    The Netherlands
    Posts
    196
    Vote Rating
    0
    nicobarten is an unknown quantity at this point

      0  

    Default


    I'm using 4.1.1a and i'm still having this problem.

  10. #10
    Sencha User
    Join Date
    May 2011
    Posts
    2
    Vote Rating
    0
    Guille is on a distinguished road

      0  

    Default


    And I am using 4.2.0 and still having this issue. In the title it states "FIXED" in what sense it is supposed to be fixed?

Similar Threads

  1. Replies: 1
    Last Post: 12 Apr 2011, 8:40 PM
  2. Replies: 2
    Last Post: 10 Apr 2011, 11:31 PM
  3. Replies: 0
    Last Post: 9 Apr 2011, 12:58 AM
  4. Replies: 1
    Last Post: 25 Mar 2011, 6:50 PM
  5. createSequense on Ext.form.Field.setValue is not executed when a record is loaded.
    By RonaldBrinkerink in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 2 Mar 2011, 3:29 AM

Thread Participants: 5