I am new to Ext-js and I encountered a peculiarity that just might be a bug.
In my Extjs 3.0 RC2 based program, using an Ext.data.ArrayReader to fill a grid works
while using an Ext.data.JsonReader to do the same job gives me
a grid containing only blank lines.
It seems that this is not by chance. Ext.data.ArrayReader is derived from Ext.data.JsonReader and
the only difference is the implementation of the readRecords method.
Closer inspection leads me to suspect the following method in Ext.data.JsonReader.
// private extractValues
extractValues: function(data, items, len) {
var f, values = {};
for(var j = 0; j < len; j++){
f = items[j];
var v = this.ef[j](data); // v is always undefined
values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
}
return values;
},
The values extracted are from the json data object are always undefined. Probably because
they are extracted by name instead of being extracted by position.
I have proposed a merger whereby JsonReader and ArrayReader become one, and it just uses either numeric indices or string property names: http://extjs.com/forum/showthread.php?t=69453
They are different classes. Using them to do the same job is wrong.
Originally Posted by Animal
I have proposed a merger whereby JsonReader and ArrayReader become one, and it just uses either numeric indices or string property names: http://extjs.com/forum/showthread.php?t=69453
But no response from the dev team.
Thanks!
I can't imagine why it would be deemed appropriate for a JsonReader class to not properly deal with JSON encoded data.
But then again I do not know Javascript very well and maybe arrays are not objects in Javascript.
Anyway if the JsonReader were to have properly dealt with arrays it would have saved me quite a bit of debugging.