Yes. ExtJs does not yet have a reader capable of handling string lists. On the server side (at least in Java, C #, etc.) Often there is what you get when sorting ENUM types.
I had to write my own class, which is used in ExtJs 4.1 MVC style:
Ext.define('MY.store.EnumReader', {
extend: 'Ext.data.reader.Json',
alias: 'reader.enum',
getData: function(data) {
var me = this;
var prop = Ext.isEmpty(this.fieldName) ? 'name' : this.fieldName;
console.log('Using the model property: \''+ prop +'\' to set each enum item in the array');
try {
var enumArray = me.getRoot(data);
if (!Ext.isArray(enumArray)){
console.error("expecting array of string (i.e. enum)");
throw new Exception('not an array of strings - enum');
}
var enumToObjArray = Array.map(enumArray, function(item){
var obj = {};
obj[prop] = item;
return obj;
}
);
var nodes = me.root.split('.');
var target = data;
var temp = "data";
Array.forEach(nodes, function(item, index, allItems){
temp += "['" + item + "']";
});
temp += " = enumToObjArray";
eval(temp);
return data;
}
catch(ex){
console.error('coudln\'t parse json response: ' + response.responseText);
return this.callParent(response);
}
}
}, function() {
console.log(this.getName() + ' defined');
});
Then, if you want to use this type of reader in your store, you add:
requires: ['My.store.EnumReader'],
...
proxy: {
type: 'ajax',
url: ...
reader: {
type: 'enum',
source
share