Can I display two / three months?

Can I display two / three months?

+3
source share
6 answers

The documentation for FullCalendar should help you answer this (which is well documented, BTW). I found this to quickly find the answer.

EDIT: Digging a little more, I found this one that indicates that this is not the main function, but there are some things you can do to mimic what you want.

+1
source

Even I wanted the same thing and did something like this.

<table width="100%" cellpadding="5" cellspacing="5"> <tr> <td> &nbsp; </td> <td> <input type="button" id="myprevbutton" value="&nbsp;&#9668;&nbsp;" />&nbsp; <input type="button" id="mynextbutton" value="&nbsp;&#9658;&nbsp;" />&nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td width="33%"> <div id='calendar0'> </div> </td> <td width="33%"> <div id='calendar1'> </div> </td> <td width="33%"> <div id='calendar2'> </div> </td> </tr> </table>

and in js

 $(document).ready(function() { var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#calendar0').fullCalendar({ header: { left: '', center: 'title', right: '' }, month:m-1, theme: true, }); $('#calendar2').fullCalendar({ header: { left: '', center: 'title', right: '' }, month:m+1, theme: true, }); $('#calendar1').fullCalendar({ header: { left: '', center: 'title', right: '' }, theme: true, editable: false, }); $('#myprevbutton').click(function() { $('#calendar0').fullCalendar('prev'); $('#calendar1').fullCalendar('prev'); $('#calendar2').fullCalendar('prev'); }); $('#mynextbutton').click(function() { $('#calendar0').fullCalendar('next'); $('#calendar1').fullCalendar('next'); $('#calendar2').fullCalendar('next'); }); }); 
+3
source

TL; DR
Cannon has published a modified FullCalendar , which allows the calendar to span more than one month, however it seems to work all months, and is associated with an earlier version of FullCalendar.

Here I take 3 separate calendars that hide the navigation on two calendars and synchronize the months in the main calendar: jsFiddle

More details

Set up 3 calendars - in my case, the main calendar with smaller "look back / look forward" calendars in the next and previous months:

 <div id='calendarPrev' style='width:50%'></div> <div id='calendarCurrent' style='width:100%'></div> <div id='calendarNext' style='width:50%'></div> 

There is a calendar initialization function with the option hides navigation:

 function initCalendar($calendarDiv, displayDate, isMain) { $calendarDiv.fullCalendar({ defaultDate: displayDate, header: { left: 'title', center: '', right: isMain ? 'today prev,next' : '' }, events: ... eventdata callbacks etc }); } 

In $(document).ready set the start date of the three calendars today, but exactly 1 month apart, hiding navigation on two secondary calendars. Then connect additional event handlers to the buttons "main" calendar next and prev , which synchronize 3 calendars:

 $(document).ready(function() { initCalendar($('#calendarCurrent'), moment(), true); initCalendar($('#calendarPrev'), moment().subtract(1, 'months'), false); initCalendar($('#calendarNext'), moment().add(1, 'months'), false); $('body').on('click', 'button.fc-prev-button', function() { $('#calendarPrev').fullCalendar('prev'); $('#calendarNext').fullCalendar('prev'); // allow main calendar event to propogate }); $('body').on('click', 'button.fc-next-button', function() { $('#calendarPrev').fullCalendar('next'); $('#calendarNext').fullCalendar('next'); // allow main calendar event to propogate }); } 
+1
source

@John Smith - I created 3 calendars, and so far it works for me, but instead of dragging events, mines simply save the name of the events, start, end the ability to edit them.

0
source

One alternative is possible; show the required number of weeks in the basicWeek view. It displays a tab showing 2 months.

 $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,basicWeek,basicDay' }, views: { basicWeek: { type: 'basic', duration: {weeks: 8}, rows: 8 } } } 
0
source

Add to the first, second, and third months:

 defaultDate:'2016-07-01', 
-2
source

All Articles