我在下面提供了一个TimelineResourceView作为参考,作为当前设置的示例。
示例:如果周视图为Sun-Sat,则随时向前/向后导航,始终显示从周范围前3天开始的周视图。然后,任何时候向前/向后导航时,始终显示从周范围的前3天的周视图。
FullCalendar示例时间线ResourceWeekView https://codepen.io/motogeek/pen/yLLpjLV
我从文档中尝试了许多不同的东西,比如"visiblerange“和强制日期,但都没有成功。
https://fullcalendar.io/docs/visibleRange
周日10月27日-周六11月2日,但他们希望看到10月24日周四-11月2日周六,以显示之前的3天。
calendar.setOption('visibleRange', {
start: '2019-10-24',
end: '2019-11-02'
});发布于 2019-11-06 07:03:30
坚持不懈是有回报的。我使用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://stackoverflow.com/questions/58701128
复制相似问题