持久性得到回报。我使用VisibleRange和Moment javascript库实现了自定义视图。我自己回答这个问题,因为我知道这可能对其他人提出自定义视图很有帮助。我的注意力集中在timelineResourceViewm上,但应该能够应用于其他日/周视图等。
请参阅CodePen:
Working Example Week View with Previewing Last 3 days (10 Day View)
document.addEventListener('DOMContentLoaded',function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl,{
plugins: [ 'interaction','resourceTimeline' ],timeZone: 'UTC',header: {
left: 'today',center: 'title',right: 'resourceTimeline'
},defaultView: 'resourceTimeline',views: {
resourceTimeline: {
visibleRange: function (currentDate) {
// Generate a new date for manipulating in the next step
var startDate = new Date(moment(currentDate).startOf('week').format("YYYY-MM-DD"));
var endDate = new Date(moment(currentDate).startOf('week').format("YYYY-MM-DD"));
// Adjust the start & end dates,respectively
//10 Day WeekView PREV Thurs -> Sun-Sat
startDate.setDate(startDate.getDate() - 3); //Set Past (show back Thur)
endDate.setDate(endDate.getDate() + 7); // Set Future (standard week from Sun)
return { start: startDate,end: endDate };
}
}
},slotLabelFormat: [{ weekday: 'short',month: 'numeric',day: 'numeric',omitCommas: true }],slotLabelInterval: { days: 1 },editable: true,resourceLabelText: 'Rooms',resources: 'https://fullcalendar.io/demo-resources.json?with-nesting&with-colors',events: 'https://fullcalendar.io/demo-events.json?single-day&for-resource-timeline'
});
calendar.render();
document.getElementById('prev').addEventListener('click',function() {
calendar.incrementDate({ days: -7 });
});
document.getElementById('next').addEventListener('click',function() {
calendar.incrementDate({ days: 7 });
});
});
本文链接:https://www.f2er.com/3163699.html