1. #11
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    We're looking at how to improve support for this in 4.1 and 4.2, it's too hard right now
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  2. #12
    Sencha Premium Member
    Join Date
    May 2007
    Location
    USA
    Posts
    73
    Vote Rating
    0
    notjoshing is on a distinguished road

      0  

    Exclamation success handler bug

    success handler bug


    Thanks, all, for this; it helped me isolate a problem I was having in Ext 4.0.2. In my code, I had success/failure handlers on the save events:
    PHP Code:
                record.save({
                    
    success : function(record) {
                        
    //MyData.object stores some variables before this.
                        
    var record MyData.object.record;
                        
    record.commit();
                        var 
    win MyData.object.window;
                        
    win.close();
                        var 
    s   MyData.object.store;
                        
    s.sync();
                    },
                    
    failure : function(recordop) {
                        
    Ext.Msg.alert("Save error!",
                            
    op.request.scope.reader.jsonData["error"]);
                    }
                }); 
    The success handler wasn't being called, and I isolated why. Here's the 4.0.2 save function definition:

    PHP Code:
        save: function(options) {
            
    options Ext.apply({}, options);

            var 
    me     this,
                
    action me.phantom 'create' 'update',
                
    record null,
                
    scope  options.scope || me,
                
    operation,
                
    callback;

            
    Ext.apply(options, {
                
    records: [me],
                
    action action
            
    });

            
    operation Ext.create('Ext.data.Operation'options);

            
    callback = function(operation) {
                if (
    operation.wasSuccessful()) {
                    
    record operation.getRecords()[0];
                    
    //we need to make sure we've set the updated data here.
                    //Ideally this will be redundant once the
                    //ModelCache is in place
                    
    me.set(record.data);
                    
    record.dirty false;

                    
    Ext.callback(options.successscope, [recordoperation]);
                } else {
                    
    Ext.callback(options.failurescope, [recordoperation]);
                }

                
    Ext.callback(options.callbackscope, [recordoperation]);
            };

            
    me.getProxy()[action](operationcallbackme);

            return 
    me;
        }, 
    These two rows each fail silently:

    PHP Code:
                    me.set(record.data);
                    
    record.dirty false
    If you don't have a success callback, you won't see an error; your success callback just won't get called I've overridden these two lines in my code, and all seems well.

    Has anyone else seen this?

    Josh
    Using:
    ExtJS 2.2, 3.2, 4.0.7a
    WinXP SP3
    FF10,6; IE6; IE8; Safari

  3. #13
    Sencha User
    Join Date
    Jun 2009
    Posts
    3
    Vote Rating
    0
    altrange is on a distinguished road

      0  

    Default


    The problem is here -
    HTML Code:
    record = operation.getRecords()[0];
    But, operation.getRecords method is undefined.

    So, I'm using
    PHP Code:
    record operation.records[0]; 

  4. #14
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    We've given sync the ability to take callbacks in 4.1, we'll get it into your hands as quickly as possible. Sorry for shipping such a difficult API in 4.0
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  5. #15
    Sencha User
    Join Date
    Jan 2012
    Posts
    36
    Vote Rating
    0
    Sneha004 is on a distinguished road

      0  

    Default


    Quote Originally Posted by powellke View Post
    You can get access to the returned json data from the operation argument to the success and failure functions. For example, when I call save on a "user" record and the save fails on the server side, I can return the failure json:


    { "success": "false", "message": "Error message goes here." }


    and get it from the op:


    user.save({
    success: function(rec, op) {
    // do something
    },
    failure: function(rec, op) {
    Ext.Msg.alert("Failed",op.request.scope.reader.jsonData["message"]);
    }
    });


    It took a little digging to find that, but it's there.
    Can I use success() and failure() function inside store.load({}) in ExtJs4?
    I tried ,But its not working .

    My code as :
    store.load({
    success: function(rec, op) {
    alert('success');
    },
    failure: function(rec, op) {
    alert('failure');
    }
    });

    I have tried also using callback function() inside store.load() , but unfortunately its also not working.

    Please provide some reasonable solution as soon as possible.

  6. #16
    Sencha User
    Join Date
    Jul 2011
    Posts
    9
    Vote Rating
    0
    neaplus is on a distinguished road

      0  

    Default 4.1 store sync callback abilities

    4.1 store sync callback abilities


    the documantation says there is success callback ability added to 4.1 but i cant get it work, someone can try it?

  7. #17
    Sencha User
    Join Date
    Jan 2012
    Posts
    36
    Vote Rating
    0
    Sneha004 is on a distinguished road

      0  

    Default


    But I am using ExtJs4.0 .

    Can any one give solution how to get json data from service response which should reflect on the grid ?

    Please give me the solution as soon as possible.
    I have used callback() function inside store.load({});
    It is working some times after debugging the store.load({}) and some times its not working .
    I have tried a lot.

    If anybody have any suggestion , Please clarify.
    I need yours help.

    Thank you

  8. #18
    Sencha User
    Join Date
    Dec 2011
    Posts
    16
    Vote Rating
    0
    dllchrist is on a distinguished road

      0  

    Default


    bump this, i can't get it work on extjs 4.1 either.

  9. #19
    Sencha User olecom's Avatar
    Join Date
    Oct 2011
    Location
    Republic of Belarus
    Posts
    36
    Vote Rating
    1
    olecom is on a distinguished road

      0  

    Default


    Quote Originally Posted by dllchrist View Post
    bump this, i can't get it work on extjs 4.1 either.
    .
    Extjs 4.1-rc2, store with REST proxy, on server side nodeJS + expressJS work for me:
    Code:
    store.sync({success: sfun(batch, opts), failure: ffun(batch, opts)})
    As for API. Call `store.sync()` returns useless store itself. But `return needsSync` will say that there will be no async calls to either handler, which is great to know BTW. It's possible to make finishing job right now.

  10. #20
    Sencha User olecom's Avatar
    Join Date
    Oct 2011
    Location
    Republic of Belarus
    Posts
    36
    Vote Rating
    1
    olecom is on a distinguished road

      0  

    Default ExtJS 4.1.1 src\data\AbstractStore.js

    ExtJS 4.1.1 src\data\AbstractStore.js


    While doing store sync there are 3 possible code branches:
    Code:
    sync_processing_ui_updates()
    Code:
    if(needsSync) success_call_back_ui_updates()
    Code:
    if(needsSync) fail_call_back_ui_updates()
    Code:
    if(!needsSync) no_sync_call_ui_updates()
    Thus returning needsSync from store.sync() call manages all possible branches easily.