PDA

View Full Version : Combo Box on Form Custom Renderer



blomasky
26 Mar 2014, 10:35 AM
Is there a Renderer function (like I have for columns in grids) for a combo box on a panel? I want to customize the display field depending on other columns in the grid?

Thanks
Bruce

firefoxSafari
26 Mar 2014, 10:44 AM
It's not quite the same, but you do have access to the tpl and displayTpl properties to control the look of the combo box display.

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.field.ComboBox
Customized combobox



// Template for the dropdown menu.
// Note the use of "x-boundlist-item" class,
// this is required to make the items selectable.
tpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<div class="x-boundlist-item">{abbr} - {name}</div>',
'</tpl>'
),
// template for the content inside text field
displayTpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'{abbr} - {name}',
'</tpl>'
)

blomasky
26 Mar 2014, 11:08 AM
I did see that in the doc, however, I am using SA 3 and I don't see a property for tbl or displayTplAlso, I need to do some conditional output depending on the value of another field:i.e if (record.data.parentID >0) return '' + record.data.description + '

firefoxSafari
26 Mar 2014, 11:19 AM
Not sure why SA3 doesn't expose these. If nothing else, I think you could put them in a Process Config function.

The XTemplate is capable of doing conditional logic. It has a basic if test built in as well as the potential of adding template member functions to execute arbitrary JavaScript code. I've used this before to conditionally style certain entries in a ComboBox.

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.XTemplate

blomasky
26 Mar 2014, 12:45 PM
THANKS! That gave me a good place to look at. All seems good now (crossing fingers and toes!)bruce