PDA

View Full Version : Best way to preprocess data received from a remote proxy?



quaidbrown
11 Jan 2012, 2:19 PM
What's the best way to catch the data coming from a remote request and edit it before it is displayed or used in any way? Should I be looking the proxy or the reader? Catching a load event or overriding a read method somewhere?

mitchellsimoens
12 Jan 2012, 8:28 AM
I would do this in the reader like the getResponseData method. It's past the raw data and all it does is decode the data and return it in javascript form.

quaidbrown
12 Jan 2012, 10:00 AM
What's the best way to do that? I tried this:


reader: {
type: 'json',
root: 'GetAppointmentsResult',
getResponseData : function(response){
console.log(response);
//this.callParent(); // Uncaught TypeError: Cannot call method 'apply' of undefined
this.superclass.getResponseData(this) //Cannot read property 'success' of undefined
}

quaidbrown
12 Jan 2012, 12:34 PM
This should be an easy one... how do I override a method? This seems like it should work.



reader: { type: 'json', root: 'GetAppointmentsResult', getResponseData : function(response){ console.log(response); //this.callParent(arguments); // Uncaught TypeError: Cannot call method 'apply' of undefined this.superclass.getResponseData(this, response) //Cannot read property 'success' of undefined }

quaidbrown
12 Jan 2012, 2:23 PM
Ext.define('AM.store.MyReader',{
extend: 'Ext.data.reader.Json',
alias : 'reader.myreader'

});


AM.store.MyReader.override({
getResponseData : function(response) {
console.log("in overridden getResponseData");
return this.callOverridden(arguments);
}
});