PDA

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



Fire-Dragon-DoL
13 Jun 2012, 5:08 PM
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!

Fire-Dragon-DoL
14 Jun 2012, 1:50 AM
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.

sword-it
14 Jun 2012, 2:36 AM
Hi!
You could also just use the success and failure events, or you should catch exception event
Try This:




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

Fire-Dragon-DoL
14 Jun 2012, 4:36 AM
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.

Fire-Dragon-DoL
14 Jun 2012, 8:23 AM
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":


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.

wiznia
20 Feb 2013, 7:17 AM
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)
});

Fire-Dragon-DoL
20 Feb 2013, 7:32 AM
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

wiznia
20 Feb 2013, 8:40 AM
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...