Question

I am trying to fill a datefield with todays date by doubleclicking the datefield. now I have no clickevent for xtype: datefield.

is it possible to still 'add' a doubleclick event to a datefield, or is there another workaround??

example code:

xtype: 'datefield',
name: 'reminderDate',
itemId: 'reminderDate',
fieldLabel: 'Erinnerung am',
padding: '10',
style: 'background-color: red'
Was it helpful?

Solution

Ext.form.field.Date does not have dblclick event. However after component is rendered you can bind listener for dblclick event on datefield input element. You can get datefield input element from Ext.form.field.Date inputEl property.

xtype: 'datefield',
fieldLabel: 'Date',
name: 'date',
listeners: { 
    afterrender: function(c) {
        c.inputEl.on('dblclick', function(){
            c.setValue(new Date());
        });
    }
}

Live fiddle with example: https://fiddle.sencha.com/#fiddle/2bo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top