View Full Version : DateField and select event.

21 Oct 2008, 3:50 AM
Hi when your are using comboBox on toolBar the select event is funy way to react on choise in your combo, for using combo same as menu wath display selected value.

But if you want DateField you don't have select event. you need use simple Field to display the value and DatePicker on a menuButton to selct the date.

you can add the select event to DateField whith

var dt= new Ext.form.DateField({...});
dt.menuListeners.select = function(m, d){
this.fireEvent('select', this, d);

same as comboBox you can now handle the select event on your DateField


9 Mar 2009, 6:37 AM
The DateField documentation (http://extjs.com/deploy/dev/docs/?class=Ext.form.DateField) says it should do so out of the box, but it doesn't work for me.
Used your trick then, correcting it for all the DatePickers:

Ext.form.DateField.prototype.menuListeners = Ext.applyIf( function() {
var original_select = Ext.form.DateField.prototype.menuListeners.select;
return {
select: function( m, d ) {
// legacy:
original_select.apply( this, arguments );
// fix:
this.fireEvent( 'select', this, d );
}(), Ext.form.DateField.prototype.menuListeners );

But you want to be careful firing events like this, especially when you upgrade your ExtJS version. Else you may end up firing the event twice... Therefore I'll put this code in a separate JS file, so that I'll just comment it when the bug is fixed.

9 Mar 2009, 6:55 AM
That code is in 2.2.1, it should work correctly if you have the latest release.

9 Mar 2009, 7:35 AM
Okay, I was still in 2.2