PDA

View Full Version : How to detect month or year change in date picker?



ttbgwt
11 May 2012, 7:09 AM
http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/form/adv-vtypes.html
(http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/form/adv-vtypes.html)
35128

friend
11 May 2012, 9:33 AM
It you want this to be done globally, it's easiest to do an override on Ext.picker.Date.showPrevMonth() and Ext.picker.Date.showNextMonth():



Ext.override(Ext.picker.Date, {
showPrevMonth: function(e) {
console.log('The User clicked the show PREVIOUS month button! ');
this.callParent(e);
},
showNextMonth: function(e) {
console.log('The User clicked the show NEXT month button! ');
this.callParent(e);
},
});


Otherwise, you could extend an instance of a datefield's picker and do a one-off override.

You can do the same sort of thing for the Year selector as well. Take a look at the source code for Ext.picker.Date (http://docs.sencha.com/ext-js/4-0/source/Date3.html#Ext-picker-Date).