View Full Version : multiple values in a combo box

30 Apr 2010, 6:15 AM
How can I show 2 concatenated fields in a combo box (i.e. UserID and User Name - something like "JOHNQ - Analyst John Quincy", but when the user clicks on a value in the combo box, they get only the UserID - "JOHNQ"?

30 Apr 2010, 10:57 AM
Probably easiest to just concatenate the values on your backend script before you send it to the combobox. Otherwise you could make use of a template to render the list items on the combo...

30 Apr 2010, 11:26 AM
OK, but how do I show just the UserID in the text box over which the combo box sits, when the user selects the concatenated values?

30 Apr 2010, 12:46 PM
add this to the combo and put in your own values, i use this and works for me

tpl: '<tpl for="."><div class="x-combo-list-item">{mac_address} - {part_number}</div></tpl>',

here is my whole combo example

var cmPhoneMacForm = new Ext.form.ComboBox({
dataIndex: 'cmphonemac',
tpl: '<tpl for="."><div class="x-combo-list-item">{mac_address} - {part_number}</div></tpl>',
store: devicestore,
mode: 'local',
fieldLabel: 'Phone',
id: 'mac',
name: 'mac',
displayField: 'mac_address',
triggerAction: 'all',
selectOnFocus: true,
allowBlank: true

and i only pull the macaddress value in this example

3 May 2010, 8:12 AM
Works great! Thanks

sencha beginner
17 Sep 2014, 7:50 AM
after this, how to save the concatenated String(for e.g. 'abc' concatenated with 'xyz' showing as 'abc-xyz' in option) in combo on selection?? because when I select, it will enter 'xyz' only...
Please help.