In your script, you used ArrayStore , which is not intended for this purpose, but rather a two-dimensional array in a dataset in which the model does not exist. Note that I used a regular store in the following example.
Regardless of whether you explicitly create a data model or not, the store will look for values with respect to the key (field name) in the object. ie , if you specified the name and description fields, then it will look for a data array structured as follows:
{ name: 'Record Name', description: '...' }
To get around this in the interface, you can apply transform to the reader configuration, which allows you to manipulate a raw data object before it is processed by any other components. For instance:
var store = Ext.create('Ext.data.Store', { fields: ['name'], autoLoad: false, proxy: { type: 'ajax', url: 'data.json', reader: { type: 'json', rootProperty: 'GetDepartementsResult', transform: function(data){ var key = this.getRootProperty(); data[key] = data[key].map(function(val){ return { name: val }; }); return data; } } } });
Thus, you have a clear field called name , which you can use to configure both displayField and valueField in your combo box.
& raquo; violin
source share