I created custom json reader as suggest by James Clark in following post.
Here is a code for creating custom json
Ext.define('MyReader', {
extend: 'Ext.data.reader.Json',
alias: 'my-json',
read: function (object) {
debugger;
object.Results = Ext.decode(object.responseText);
this.callParent([object]);
}
});
In store definition I assing custom reader
var store = Ext.create('Ext.data.Store', {
//model: 'Option',
fields: fields,
pageSize: itemsPerPage,
proxy: {
type: 'ajax',
url: getDataWithPageURL,
**reader:Ext.create('MyReader', {root: 'Results', totalProperty: 'Total'})**
}
});
The json that I receiving from clients look like this
{"Results":["{\"BaseCurrency\":\"USD\",\"TermCurrency\":\"JPY\"}","{\"BaseCurrency\":\"USD\",\"TermCurrency\":\"JPY\"}","{\"BaseCurrency\":\"USD\",\"TermCurrency\":\"JPY\"}","{\"BaseCurrency\":\"USD\",\"TermCurrency\":\"JPY\"}"],"Total":4}
I receiving an error in ext-js.js
I debuged it and the error occurs in Ext.data.proxy.Server class in
following code
if (success === true) {
reader = me.getReader();
result = reader.read(me.extractResponseData(response));
records = result.records;
result is undefined.
Please help
The problems with the code in my initial attempt were:
The alias should have been
'reader.my-json'The results needed to be mapped because it was an array:
With those fixed, the store can use the simpler reader definition:
But see the complete test case in the original question for the full code. I apologize for not having thoroughly tested the code I initially proposed.