Reputation: 11
I need to display the weeks of any month in a calendar. I am trying to figure out how could that be done using FullCalendar but I am having a hard time. Do I need to make a custom render? or is it a complete modification?
Thanks.
Link to a descriptive image of the desired result: https://i.sstatic.net/iPRB2.png
Upvotes: 1
Views: 2960
Reputation: 1212
I've gotten this working including when you click the arrow button (v1.5.3):
Add showWeekNumbers: false
as part of the defaults.
Go to around line 2241 and close off the string concatentation. Then add this code:
if(j == 0 && calendar.options.showWeekNumbers) {
s += "<div class='fc-week-number' />";
}
Then go to around line 2308 and in bodyCells.each add this code:
if(i % 7 == 0 && calendar.options.showWeekNumbers) {
cell.find('div.fc-week-number').text(date.getWeek());
}
Then you just need to add this code to calculate the week:
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
var week = Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
return week;
}
If you then add the option showWeekNumbers: true
this will work.
Upvotes: 1