View Full Version : ComboBox getValue returns display field value

5 Apr 2012, 9:46 AM
Below is a definition for a store and combobox (don't comment on the style of the store definition this is generated by the designer). You can see that a the combobox is defined to use the 'value' field for it's value and the 'name' field as its display fields. However calls to comboBox.getValue(), comboxBox.getRawValue() and comboBox.getDisplayValue() all return the content of the 'name' field while I was expecting the getValue() and getRawValue() functions to return the value of the value field.

How should I be configuring the combobox so the getValue() function returns the value rather than the name?

I see the same behavior when using 4.0.7 and the nightly build from 0404.


{ xtype: 'combobox',
id: 'clusterTypes',
fieldLabel: 'Cluster type',
labelWidth: 70,
allowBlank: false,
editable: false,
autoSelect: false,
displayField: 'name',
store: 'ClusterTypes',
valueField: 'value'


Ext.define('CircularRelationships.store.ClusterTypes', { extend: 'Ext.data.Store',
requires: ['CircularRelationships.model.ClusterType'],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
storeId: 'ClusterTypes',
model: 'CircularRelationships.model.ClusterType',
data: [
{name: 'Name', value: 'name'},
{name: 'Popularity', value: 'popularity'},
{name: 'Related tags',value: 'tags'},
{name: 'Number of relationships',value: 'rels'}
proxy: {type: 'memory'}
}, cfg)]);

5 Apr 2012, 9:52 AM
My own fault. The combo box does not default to the first item so it has to be populated in code. That code does sets only a 'name' not a 'value'.