使用以下代码更改视图范围,我将渲染所有事件,但是在某些天范围内,事件将不会渲染。
在接下来的几天范围内-18、19、20或21天,事件将不会呈现,否则对于所有类型的范围都可以。
检查以下对象属性:
$('#fullcalendar_scheduler').fullCalendar('getView').timeBodyScroller.canvas.width
我得到--> "",
而不是正宽度...
有什么主意吗?是否存在已知问题?
$('#fullcalendar_scheduler').fullCalendar('option', 'visibleRange', {
start: new Date(startDate).yyyymmdd(),
end: dateAdd(startDate, currentDurationCount, $('#zoom-scale-selector').val()).yyyymmdd(),
});
以下函数获取开始和结束日期,我还将发布dateAdd函数:
function updateTimelineDuration(start_date, end_date) {
if (typeof start_date === 'undefined' || start_date === null || start_date.length == 0) {
start_date = $.trim($("#start_date").val()).substring(0, 10);
}
// If we have no 'start_date', from any source, don't do anything
if (typeof start_date === 'undefined' || start_date === null || start_date.length == 0) {
return;
}
var startDate = new Date(start_date);
if (typeof end_date === 'undefined' || end_date === null || end_date.length == 0) {
end_date = dateAdd(startDate, currentDurationCount - 1, $('#zoom-scale-selector').val());
}
var endDate = new Date(end_date);
var conversionDivisor;
switch ($('#zoom-scale-selector').val()) {
case 'month':
// TODO: Fix me
// 1 month (30 days) = 2592000000 ms
conversionDivisor = (1000 * 60 * 60 * 24 * 30);
break;
case 'week':
// 1 week = 604800000 ms
conversionDivisor = (1000 * 60 * 60 * 24 * 7);
break;
case 'day':
default:
// 1 day = 86400000 ms
conversionDivisor = (1000 * 60 * 60 * 24);
}
currentDurationCount = Math.round((endDate - startDate) / conversionDivisor) + 1;
if (currentDurationCount < 1) { currentDurationCount = 1; }
// Adjust timeline
$('#fullcalendar_scheduler').fullCalendar('changeView', 'timeline', new Date(startDate).yyyymmdd());
$('#fullcalendar_scheduler').fullCalendar('option', 'visibleRange', {
start: new Date(startDate).yyyymmdd(),
end: dateAdd(startDate, currentDurationCount, $('#zoom-scale-selector').val()).yyyymmdd(),
});
$('#fullcalendar_scheduler').fullCalendar('render');
// Update zoom-text
$('#zoom-text').text(currentDurationCount);
}
这是dateAdd函数:
function dateAdd(date, interval, units) {
var ret = new Date(date); // don't change original date
var checkRollover = function () { if (ret.getDate() != date.getDate()) ret.setDate(0); };
switch (units.toLowerCase()) {
case 'year': ret.setFullYear(ret.getFullYear() + interval); checkRollover(); break;
case 'quarter': ret.setMonth(ret.getMonth() + 3 * interval); checkRollover(); break;
case 'month': ret.setMonth(ret.getMonth() + interval); checkRollover(); break;
case 'week': ret.setDate(ret.getDate() + 7 * interval); break;
case 'day': ret.setDate(ret.getDate() + interval); break;
case 'hour': ret.setTime(ret.getTime() + interval * 3600000); break;
case 'minute': ret.setTime(ret.getTime() + interval * 60000); break;
case 'second': ret.setTime(ret.getTime() + interval * 1000); break;
default: ret = undefined; break;
}
return ret;
}