-
12 Oct 2012 10:41 AM #1
Override ArrayReader's readRecords() method to convert data from server
Override ArrayReader's readRecords() method to convert data from server
Hi
ExtJS 3.4.0
I need to convert data to a different format and I'm attempting to do this by overriding the readRecords() method.
So far this code gives an error after the 'readRecords:' console message.
Any help or suggestions or links to samples would be appreciated.
Code:readRecords: TypeError: b is undefined
Code:var MyFields = Ext.data.Record.create([ {name: 'id'}, {name: 'name'} ]); MyReader = Ext.extend(Ext.data.ArrayReader, { fields: MyFields, readRecords: function(o) { console.log('readRecords:'); MyReader.superclass.readRecords.apply(this, o); } }); MyStore = Ext.extend(Ext.data.ArrayStore, { reader: new MyReader() });
-
13 Oct 2012 9:21 AM #2
So this field in the reader can convert the value you are parsing to the one you want. Here you can see that i get from server only a string "false" or "true" and with this function i change it for a boolean true or false. I hope it helps ?

PHP Code:{
name: 'released',
mapping: 'realeased',
convert: function(v, r){
var ret = false;
if (v == "true") {
ret = true;
}
return ret;
}
}
-
13 Oct 2012 8:12 PM #3
This thread describes what I need to do, but in Sencha Architect.
HOWTO - reformat data sent from server at the Store
http://www.sencha.com/forum/showthread.php?243849
I need to do the same thing in ExtJS 3.4.0
Any help/suggestions would be greatly appreciated.


Reply With Quote