I want to display a message from my server in the UI after synchronizing an ExtJS grid. Here's an excerpt of how that goes:
this.store.sync({
callback: function (records, operation, success) {
// messageProperty accessing code
},
success: function (batch, options) {
// messageProperty accessing code
},
failure: function (batch, options) {
}
});
Here's a piece of the store definition:
proxy: {
headers: { 'Accept': 'application/json' },
limitParam: undefined,
pageParam: undefined,
startParam: undefined,
paramsAsJson: false,
type: 'ajax',
// ...
reader: {
type: 'json',
rootProperty: 'Data',
messageProperty: 'Message'
},
// ...
},
Here's some data that comes back from the server (omitted the data inside the array:
{
"Data":[
],
"Message":"Success!"
}
The application doesn't seem to have issues with reading the data property (i.e. my grid works properly), but I'm not able to access the message property in either the callback or success event of the sync method. This is the error message:
Uncaught TypeError: Cannot read property 'Message' of undefined(…)
createAccessor: (function () {
var re = /[\[\.]/;
return function (expr) {
var me = this,
simple = me.getUseSimpleAccessors(),
operatorIndex, result, current, parts, part, inExpr, isDot, isLeft, isRight, special, c, i, bracketed, len;
if (!(expr || expr === 0)) {
return;
}
if (typeof expr === 'function') {
return expr;
}
if (!simple) {
operatorIndex = String(expr).search(re);
}
if (simple === true || operatorIndex < 0) {
result = function (raw) {
return raw[expr]; <-------- This is where it goes wrong at some point
};
}
If I debug through this code, at some point the raw variable loses its value, which gives the expected undefined error message. My question is how I could be able to retrieve the message property in the callback or success functions of an Ext 6 store?