Reputation: 91
I want something like this:
{
xtype:'datefield',
editable:false,
fieldLabel:'date',
listeners:{
monthChange:function(picker){
alert("selected month and year")
}
}
}
Is there any event for month change? If not, how can I write it?
Thanks
Upvotes: 0
Views: 3391
Reputation: 191
This is an example of extending 'Ext.date.Picker' as there is no 'monthchange' event:
Ext.define("YourCalendarPicker", {
extend: "Ext.picker.Date",
...
update : function(date, forceRefresh){
var me = this,
monthViewChange = me.isAnotherMonthView(date);
me.callParent(arguments);
if (monthViewChange){
me.fireEvent("monthviewchange", me, date, me.activeDate);
}
return me;
},
...
/**
* return true if the given date is in a different month view of the actual calendar date
* @param {Date} date
* @return {Boolean}
*/
isAnotherMonthView: function(date){
var activeDate = this.activeDate || date;
return date.getYear() != activeDate.getYear() || date.getMonth() != activeDate.getMonth();
}
};
Upvotes: 3
Reputation: 12624
There isn't a monthChange event exactly, but you can listen when someone picks a new date, then maybe you could compare the month to see if it changed? http://docs.sencha.com/ext-js/4-1/#!/api/Ext.picker.Date-event-select
A little more info would be helpful if this isn't the problem you are trying to solve.
Upvotes: 1