View Full Version : Format textfield in combobox like in tpl

22 Nov 2010, 2:19 AM

I have a combobox for which the user should pick a value out of the list. The list is formatted via a tpl like:

/ (Homepage)
/page1.htm (Page1)
/page2.htm (Page2)
/page6.htm (Page6)

The problem is: After selecting a value from this, the textfield only shows
but I want it to show:
/page1.htm (Page1)
(so we have the values of 2 fields in it, including some html-formatting)

Is there any way to do so?

xtype: 'combo',
hiddenValue: '1',
name: 'id_visible',
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
selectOnFocus: true,
tpl: '<tpl for=\".\"><div class=\"x-combo-list-item\"><i>{url}</i> ({name})</div></tpl>',
store: new Ext.data.Store(
{ autoLoad: true,
proxy: new Ext.data.HttpProxy(
{ url: '/get_store.php',
method: 'POST'
reader: new Ext.data.ArrayReader(
{ root: 'data',
totalProperty: 'total',
id: 0
[ { name: 'id', type: 'string' },
{ name: 'url', type: 'string' },
{ name: 'name', type: 'string' }

25 Nov 2010, 4:14 PM
You should probably use the field convert function to setup a field that merges the values for the displayField.

27 Nov 2010, 7:31 AM
The CalcRecord extension can also be useful here to add an extra calculated field that can be used as displayField.

20 Mar 2011, 11:58 PM
Thanks for your replys, both solutions are working fine so far when loading values/hiddenValues from the store.

But I got one last problem: When setting the value/hiddenValue out of the code, you normally use setValue. But that will set both the value and the hiddenValue to the same text. How do I set 2 values (the displayed value to "/page1.htm (Page1)" and the hidden value/submitted value to an id like "1234"). Whats the way to do that?