1. #1
    Sencha User xjpmauricio's Avatar
    Join Date
    Jul 2009
    Location
    Portugal, Setúbal
    Posts
    88
    Vote Rating
    1
    xjpmauricio is on a distinguished road

      0  

    Default Answered: Store sync callback

    Answered: Store sync callback


    Hi, how can i get the callback of a store sync() ?

    Something like:
    Code:
    scope.storeDocuments.sync({
        success: function() {
    
        }, 
        failure: function() { 
    
        }
    });
    
    Can it be done without setting the "afterRequest" event on the store itself?

    Can it be done without overriding anything?

  2. unfortunately the functionality does not exist yet. I have placed a feature request for this. now let's see what the dev team decides...

  3. #2
    Ext JS Premium Member gevik's Avatar
    Join Date
    May 2009
    Location
    The Netharlands
    Posts
    265
    Answers
    2
    Vote Rating
    8
    gevik will become famous soon enough

      0  

    Default


    unfortunately the functionality does not exist yet. I have placed a feature request for this. now let's see what the dev team decides...

  4. #3
    Ext JS Premium Member gevik's Avatar
    Join Date
    May 2009
    Location
    The Netharlands
    Posts
    265
    Answers
    2
    Vote Rating
    8
    gevik will become famous soon enough

      0  

  5. #4
    Sencha User xjpmauricio's Avatar
    Join Date
    Jul 2009
    Location
    Portugal, Setúbal
    Posts
    88
    Vote Rating
    1
    xjpmauricio is on a distinguished road

      0  

    Default


    Thanks a lot Gevik, i picked up your code and converted to this:

    Ext.override(Ext.data.Store, {
    sync:
    function(config) {
    var me = this;
    me.is_sync_opr =
    true;
    var callback_handler = function() {
    if (me.is_sync_opr === true && config.callback && Ext.isFunction(config.callback)) {
    config.callback.apply(
    this, arguments);
    }
    me.sync_events =
    false;
    };
    var update_handler = function(store, record, opr) {
    if (me.is_sync_opr === true && config[opr] && Ext.isFunction(config[opr])) {
    config[opr].apply(
    this, [record, opr]);
    }
    }
    var exception_handler = function(proxy, response, opr) {
    if (me.is_sync_opr === true) {
    if (opr && opr.records && Ext.isFunction(config.reject)) {
    Ext.each(opr.records,
    function(r) {
    config.reject.apply(me, [r, opr]);
    });
    }
    }
    me.is_sync_opr =
    false;
    }
    if (me.sync_events == undefined) {
    me.model.proxy.addListener(
    'exception', exception_handler, this);
    me.addListener(
    'write', callback_handler, this);
    me.addListener(
    'update', update_handler, this);
    me.sync_events =
    true;
    }
    this.callParent();
    }
    });

Thread Participants: 1