View Full Version : Format date in combo box

19 Jun 2012, 4:25 AM

I have some dates in a store that I need to format in a combobox.
I can do this in the list items, but how can I format the display value on the selected item?


xtype: 'combobox',
disabled: true,
itemId: 'Pulje',
width: 226,
fieldLabel: 'Pulje',
labelAlign: 'top',
displayField: 'start',
forceSelection: true,
store: 'Puljer',
valueField: 'Id',
lastQuery: '',
listConfig: {
getInnerTpl: function() {
return '<div class="search-item">{start:date("Y-m-d H:i")}</div>';
listeners: {
select: {
fn: me.onPuljeSelect,
scope: me

23 Jun 2012, 2:53 PM
You can format it on select:

// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody(),

listeners: {
select: function(combo,records){
var date = Ext.Date.format(new Date(), 'Y-m-d H:i');
combo.setRawValue(date); // set raw