Friday, April 1, 2016

EXTJS: Get response from store sync operation

EXTJS sync operation is usually used to synchronize the Store with its Proxy. This asks the Proxy to batch together any new, updated and deleted records in the store, updating the Store's internal representation of the records as each operation completes. [ref. EXTJS store sync() API]

The sync operations can happen over REST calls. In case of a REST call, if the sync operations fails, how to achieve the response? Here is the way:
 store.sync({  
   success: function(batch, operations){  
      Ext.msg.Alert("store sync successful");  
   },  
   failure: function(batch, operations){  
      var response = rec.operations[0].error.response;  
      var responseText = JSON.parse(response.responseText);  
      var errorMessage = responseText.message;  
   }  
 });  


Happy coding :)

No comments:

Post a Comment