How do I determine the start and end date on the agendaWeek view in FullCalendar?

谁说胖子不能爱 提交于 2019-12-11 12:08:00

问题


I'm customizing the width and position of the events my FullCalendar with agendaWeek as the view. I need to know what the start and end dates are of the week.

I know I can use $('#calendar').fullCalendar('getDate') to get the current date and I could figure out the day of the week and calculate the start/end dates, but I'm hoping and assuming there is a property that I can read.


回答1:


If you're getting your events from a file, FullCalendar posts the start and end dates for the current week view. Take a look at this page from the official documentation: http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/

If you call FullCalendar like this:

$('#calendar').fullCalendar({
    events: '/myfeed.php'
});

The URL it will use includes a query string with the start and end UNIX timestamps:

/myfeed.php?start=1262332800&end=1265011200&_=1263178646

Note: The _ parameter is automatically inserted to prevent the browser from caching the result.

If you're generating you events by function, it similiarly provides the start and end times, but they are JavaScript Date objects. See this page from the official documentation: http://arshaw.com/fullcalendar/docs/event_data/events_function/

$('#calendar').fullCalendar({
    events: function(start, end, callback) {
       //Manipulate the start and end objects
    }
});

If you're just supplying an array of event dates (as per http://arshaw.com/fullcalendar/docs/event_data/events_array/), the start and end dates are not accessible. You will need to use one of the two methods above.




回答2:


You can get the start date using :

$('#calendar').fullCalendar('getView').start._i

Then just add up the days in the week to get your end date



来源:https://stackoverflow.com/questions/6598768/how-do-i-determine-the-start-and-end-date-on-the-agendaweek-view-in-fullcalendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!