PDA

View Full Version : [3.0-rc1] DateField menuListeners



TopKatz
17 Apr 2009, 5:04 AM
I have some DateFields that I was using menuListeners on to use some custom behavior in 2.x. Did this change? I inspected the field, and still see menuListener.select() in there, however this is not working now:



this.weDateField = new Ext.form.DateField({
disabledDays:[0,1,2,3,4,5],
value:'',
menuListeners:{
select : function(){
var date = this.weDateField.menu.picker.activeDate;
this.weDateField.setValue(date);
this.reloadWEDate();
},
scope:this
}
});


Even if I just stick a console.log('test') in the select I get nothing.

Thanks in advance

Condor
17 Apr 2009, 5:14 AM
1. Yes, this changed in Ext 3.0.
2. Your code doesn't work properly in Ext 2.x. You need:

menuListeners: Ext.applyIf({
select: function(m, d){
this.constructor.prototype.menuListeners.select.apply(this, arguments);
...
}
}, Ext.form.DateField.prototype.menuListeners)
(and you can't set the scope unless you use createDelegate)
3. In Ext 3.0 you can use:

onSelect: function(m, d){
this.constructor.prototype.onSelect.apply(this, arguments);
...
}
4. But the recommended method for 2.2.1 and 3.0 is to use a simple 'select' listener.

TopKatz
17 Apr 2009, 5:26 AM
...
4. But the recommended method for 2.2.1 and 3.0 is to use a simple 'select' listener.

Are you saying to use the datepickers select? If I remember this did not work as expected before. Ill try that.

BTW - this code is working in 2.x

Condor
17 Apr 2009, 5:31 AM
1. The select event was introduced in Ext 2.2.1 (your code probably predates Ext 2.2.1).
2. menuListeners contains 3 listeners (select, show and hide), so your method effectively kills the show and hide listeners on the inner DateMenu.

TopKatz
17 Apr 2009, 5:32 AM
your right, regular old select is working fine. Not sure how I landed on menuListeners before. I know I had issues getting select to work.

Thanks

Katz

sureshraja.crt
31 Mar 2010, 5:14 AM
Hi,
I am facing following problem while using menuListeners.select in my application.
Problem:
In my application i am using three date fields in x page. I have applied menuListeners.select for first date field. select event for first date field is working fine but all other two date fields are also getting same select effect.

Condor
31 Mar 2010, 5:22 AM
Hi,
I am facing following problem while using menuListeners.select in my application.
Problem:
In my application i am using three date fields in x page. I have applied menuListeners.select for first date field. select event for first date field is working fine but all other two date fields are also getting same select effect.

So you're making the same mistake!

I already listed the solutions in my previous post (http://www.extjs.com/forum/showthread.php?p=317909#post317909).