PDA

View Full Version : Detect when the store fail to sync (save) a model object and remove it



Fire-Dragon-DoL
31 May 2012, 7:31 AM
I'm trying to detect when a model fail to sync (save) an object, detect WHY (possibly by reading a custom field in my json called "opcode") and eventually remove this record from the store.

Which event should I use to do this? I tried update event but I'm having hard time fetching my "opcode" parameter.

Notice that I'm using an "ajax" proxy and data is in json format:

{success: false, opcode: 2, error: "My error"}

el_chief
31 May 2012, 11:17 AM
store.sync({callback: function(){})

The function to be called upon completion of the sync. The callback is called regardless of success or failure and is passed the following parameters:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-sync

"but there's no callback in my sync method"

"that's because you're using 4.0.0.0.0.0.0.1. You should always use the latest version, until there's a gold release"

"ok, thanks i will buy you a beer sometime"

Fire-Dragon-DoL
31 May 2012, 11:19 AM
Yea but there is a problem: I'm using autoSync <.<

el_chief
31 May 2012, 12:08 PM
reader.exception might help you out if it's firing an exception

or store.write if it's not