Reputation: 1950
I have a flat Calendar which can highlight the holidays & events.
It will get the stat (selected month) for calendar rendering when the calendar change month.
MyCalendar2._setCurrentFocusAttrOld = MyCalendar2._setCurrentFocusAttr;
MyCalendar2._setCurrentFocusAttr = function(d) {
//Loading the new month monthStat via the UI / KB / SelectBox
var cbFunc = function(){ MyCalendar2._setCurrentFocusAttrOld(d); };
getMonthlyStat( dateStr(d), cbFunc);
}
My problem here: how can I implement this feature into the DateTextBox ??
Aims: the DateTextBox can highlight the holidays, auto fetch the holiday when changing month.
Here is the jsfiddle.
Upvotes: 0
Views: 181
Reputation: 10559
dijit/form/DateTextBox
allows you to indicate a custom class to use for its popup calendar. So if you were to change your code around to actually create an extension of dijit/Calendar
, you could then pass that to popupClass
on a DateTextBox
instance.
Here's how you might minimally rearrange some of your code into an extension:
var CustomCalendar = declare(Calendar, {
getClassForDate: function(d) {
//mark the cell in different color to present tight
var ds = dateStr(d);
if( !isEmptyStr(calData[ds]) )
return 'mystyle_' + calData[ds];
},
_setCurrentFocusAttr: function(d) {
var self = this,
args = arguments;
getMonthlyStat(dateStr(d), function(){
self.inherited(args);
});
}
});
Then to instantiate a DateTextBox
that uses it:
var textbox = new DateTextBox({
popupClass: CustomCalendar,
constraints: constraints
}, "textbox");
Updated fiddle: http://jsfiddle.net/W4ze7/2/
You could also consider moving your utility functions into the extension, following the convention of prefixing their names with underscores to indicate that they're for internal use.
Upvotes: 1