View Full Version : setting a combobox's displayfield by a value

20 Jul 2010, 8:32 PM
Hello All.

The following is my combobox.

var companyListCombo = new Ext.form.ComboBox({
id: 'companyListCombo',
fieldLabel: 'company',
store: companyListForAddUser,
hiddenName: 'companyCode',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
editable: false

I want to set the displayfield by a value dynamically.

var addUserFormOb = addUserForm.getForm();

This displays just a code like this : '1000', but it has to display the 'companyName' by the code.

If user view the combobox after click a row of a grid which has a companyCode, then the combobox has to display a companyName by the companyCode value, and then if user submit it, it has to submit the companyCode not companyName.

How do I do this?

Thanks in advance.

20 Jul 2010, 10:32 PM
Are you sure that the combolist is already loaded before you set the value?

20 Jul 2010, 10:36 PM
No, that's why I asked.
How can I load the combolist and select the field by the value?

21 Jul 2010, 7:19 AM
Try to add "autoLoad:true" to the config of the Combobox, then set the value:

myCombobox.setValue(valueField); Since I was running into troubles with "hiddenName" some month ago I use instead :
"myCombobox.getValue()" to submit the valueField and
"myCombobox.el.dom.value" to submit displayField

Hope it helps.

21 Jul 2010, 4:27 PM
Thank you for the reply&your PM, but I don't quite understand.

What's the valueField in the code? :


21 Jul 2010, 11:52 PM
What's the valueField in the code? Sorry, that was unhandy, its only a placeholder for the var which you want to set as value in your case the same as "selectedCompanyCode".