View Full Version : ComboBox with different text/value

10 Mar 2009, 7:26 AM
I have a combo box like this:

{ xtype: 'combo',
fieldLabel: 'Interval',
name: 'interval',
editable: false,
forceSelection: false,
mode: 'local',
triggerAction: 'all',
[ ['', ''],
['7', '7 days a week'],
['3', '3 days a week'],
['2', '2 days a week'],
['1', '1 day a week']

Which of course means: If the user chooses "3 days a week", the combobox should submit the value "3".

I thought this was working already in JsEXT 2.2. and perhaps it was the update to JsEXT 2.2.1, but if I now submit the form, the value submitted is the string "3 days a week" and not "3".

What am I doing wrong?.

10 Mar 2009, 7:32 AM
You need to setup fields and map displayField, valueField and hiddenName

10 Mar 2009, 7:35 AM
Thanks for your reply. I thought this would happen automatically? The Docs for Ext.form.ComboBox.store say:

"For multi-dimensional arrays, the value in index 0 of each item will be assumed to be the combo value, while the value at index 1 is assumed to be the combo text."

And I'm quite sure this worked somehow in the past without setting up displayField and valueField.

10 Mar 2009, 7:37 AM
ok, try setting up hiddenName

10 Mar 2009, 7:42 AM
Ah, this is working. Thanks a lot!