View Full Version : Array Reader reading only the first character of the array elements.

10 Mar 2014, 1:50 AM

I have a comboBox which reads the data through a Rest Webservice, Which returns the data as a array of string as follows:


The store is attached to a combobox.
I have added a reader to my Store which uses the reader in the proxy, but the combo displays the initials of the recieved data.

the code of the store looks as :

var myReader = new Ext.data.reader.Array({ model: 'APP.model.genericmodels.dropdowns.SettingsCombo'

model: 'APP.model.genericmodels.dropdowns.SettingsCombo',
autoload: true,

proxy : {
type: 'rest',
api : {
reader: myReader

Also attaching the drop down screenshot.48218

here "C" is the initials of the data recieved (here -> College).

Please help me with the missing things.

10 Mar 2014, 1:55 AM
show us what you have in 'APP.model.genericmodels.dropdowns.SettingsCombo'

10 Mar 2014, 2:21 AM
Model: SettingsCombo

Ext.define('APP.model.genericmodels.dropdowns.SettingsCombo', {
extend: 'Ext.data.Model',

fields: [
{ name: 'name' }

10 Mar 2014, 4:30 AM
The expected format for an array reader is: "[ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]".
So in your case, it has to be: [["COLLEGE"],["SCHOOL"],["UNIVERSITY"],["TRAINING_INSTITUTE"],["FRANCHISE"]].

Also I would suggest optimizing your code.
Get rid of the model. You have only one field, so just put it in the 'fields' config of the store.
Also you can remove the reader and use a 'Ext.data.ArrayStore', which is automatically configured with a 'Ext.data.reader.Array'.
So you should get something like this:

Ext.define('APP.store.organization.OrganizationTypeStore', {
extend: 'Ext.data.ArrayStore',
autoload: true,

proxy: {
type: 'rest',
api: {
read: '/rest/pickListItem/findAllOrganizationTypes',
write: '/rest/organization/create'

Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Organization Type',
store: Ext.create('APP.store.organization.OrganizationTypeStore'),
queryMode: 'local',
displayField: 'name',
renderTo: Ext.getBody()

Good luck ;)

Interesting how you got the combo with the initials. I couldn't reproduce that!

10 Mar 2014, 8:40 PM
I did solve the problem by overriding the "getResponseData" of the reader as i was not allowed to change the format of the data as suggested by "chramer".