PDA

View Full Version : JSON Reader throws exception, but why ?



Spirit
9 Nov 2009, 2:11 AM
I have the following code which works well:


var storeSP = new Ext.data.JsonStore({
id:'wizQ',
totalProperty: 'total', // substitue with reader
successProperty: 'success', // substitue with reader
idProperty: 'id', // substitue with reader
root: 'data', // substitue with reader
fields: ['id'], // substitue with reader

proxy: proxySP,
autoSave: false,
listeners: {
load : function(store, records, options) {
// only load with filled array!
console.log('done');
},
exception : function(proxy, type, action, options, res, arg) {
console.trace();
console.log(type,action,options, res, arg);
if (type === 'remote') {
Ext.Msg.show({
title: 'REMOTE EXCEPTION',
msg: res.message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
storeSP.load();


If i substitue the lines marked above with an reader it throws an exception:


JSON send from server: {"success":"true","message":"Destroy failed","data":[{"id":"5"}], "total":"1"}

Exception:
TypeError: m is undefined message=m is undefined


The reader has the following code:


var readerSP = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
root: 'data',
fields: ['id']
}, [
{
name: 'id'
}
]);


Didnt get the point, why this isnt working.
Thx for your help.

Animal
9 Nov 2009, 5:41 AM
Use ext-all-debug.js, set Firebug to Break on all errors, and find out.