Results 1 to 8 of 8

Thread: Any event that is fired on store when success: false returned to the reader?!

  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9

    Default Answered: Any event that is fired on store when success: false returned to the reader?!

    I'm trying to create an error message that will be displayed to the user when the store fails a request.

    I can't find an event that works with it, are there any possibility? Something like aftersync, or the event update with REJECT option (which I can't find a way to fire)?

    I'm trying with all events but can't find a solution to this!

  2. It looks like nothing is implemented to watch what happened after a sync.

    I don't understand why this hasn't been done, however this is my "solution":
    Code:
    Ext.define('Fdd.data.XStore', {
        extend: 'Ext.data.Store',
    
        onCreateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onUpdateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onDestroyRecords: function(records, operation, success) {
            console.log(records);
        }
    }
    Those methods are fired whenever sync is completed, override them in your store class and create custom events.

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9

    Default

    I noticed that datachanged is not fired when a sync is called and success: false is returned.
    Are there any way to detect this behaviour? I'm sure I can't see some points here, I'm getting mad.

  4. #3
    Sencha User
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124

    Default

    Hi!
    You could also just use the success and failure events, or you should catch exception event
    Try This:

    Code:
    yourStore.on('exception',function( store, records, options ){
        // do whatever u want here
    },Your Scope);

  5. #4
    Sencha User
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9

    Default

    Mh, I can't see any 'exception' event in documentation (I tried it anyway) but I can only see it in the reader.

    I tried hooking to that event, but it's not fired, in fact as documentation stats "exception" is fired only when a parsing exception happens.

    By the way, I can't find in documentation any success/failure events.

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9

    Default

    It looks like nothing is implemented to watch what happened after a sync.

    I don't understand why this hasn't been done, however this is my "solution":
    Code:
    Ext.define('Fdd.data.XStore', {
        extend: 'Ext.data.Store',
    
        onCreateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onUpdateRecords: function(records, operation, success) {
            console.log(records);
        },
    
        onDestroyRecords: function(records, operation, success) {
            console.log(records);
        }
    }
    Those methods are fired whenever sync is completed, override them in your store class and create custom events.

  7. #6
    Sencha User
    Join Date
    Jun 2008
    Posts
    157

    Default

    WTF???? Really? There's no event fired when a sync() returns success:false ???
    The store functionality is really broken without something like this.
    The only solution I found is using the proxy's exception event...

    It would be something like:

    store.getProxy().on("exception", function(proxy, response) {
    // Here you must parse the response again, if you used a json store the response will have a responseText and you should do something like: Ext.JSON.decode(response.responseText)
    });

  8. #7
    Sencha User
    Join Date
    Dec 2011
    Posts
    141
    Answers
    9

    Default

    Quote Originally Posted by wiznia View Post
    WTF???? Really? There's no event fired when a sync() returns success:false ???
    The store functionality is really broken without something like this.
    The only solution I found is using the proxy's exception event...

    It would be something like:

    store.getProxy().on("exception", function(proxy, response) {
    // Here you must parse the response again, if you used a json store the response will have a responseText and you should do something like: Ext.JSON.decode(response.responseText)
    });
    Why don't you follow my solution? It works correctly, I used it in an application and it's fine.

    Still, I didn't believe it too: no events for "sync" when success: false, and to find those "onSomething" methods I had to dig through web/documentation/source

  9. #8
    Sencha User
    Join Date
    Jun 2008
    Posts
    157

    Default

    You are right, your solution is better... but I don't get why this isn't a functionality provided by Ext, those should be event of the store, there's no good reason to have a succes event if you don't have a failure event...

Tags for this Thread

Posting Permissions

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