我要求完整日历,从当前日期起过去15天开始,到当前日期起18个月结束
如果当前日期是2016-02-15,日历应该从2016-02-01到2017-08-15呈现,就像我们有1年的观点一样,我需要1年半的观点。这可能吗?如果没有,请以其他方式提出建议。希望你理解
Right now seeing result like in this image, click to see
Need result like in this image, click to see
我使用了这段代码
<script>
$('#calendar').fullCalendar({
events: JSON.parse(json_events),
utc: true,
theme :true,
editable: true,
eventLimit: true, // allow "more" link when too many events
header: {
left: 'today prev,next',
center: 'title',
right: 'agendaMonths'
},
defaultView: 'agendaMonths',
views: {
agendaMonths: {
type: 'timeline',
duration: { months: 18},
buttonText: '18 Months',
}
},
defaultDate :dateFormat.setDate(dateFormat.getDate()-15),
viewRender: function(view,element,currentView,cell) {
var now = new Date();
$("[data-date="+now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+addZero(now.getDate())+"]").css("background-color", "yellow");
var end = new Date();
var endback = new Date().setMonth(now.getMonth() - 17);
end.setMonth(now.getMonth() + 17); //Adjust as needed
//console.log(now +'---'+end+'--'+new Date(endback));
if ( end < view.end) {
$("#calendar .fc-next-button").hide();
}
else {
$("#calendar .fc-next-button").show();
}
if ( view.start < new Date(endback)) {
$("#calendar .fc-prev-button").hide();
return false;
}
else {
$("#calendar .fc-prev-button").show();
}
},
dayRender: function (date, cell) {
var now = new Date();
//now= now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate()-15);
now.setDate(now.getDate()-15);
now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
date=date.format("YYYY-MM-DD");
//console.log(now+'==='+date);
if (now > date) {
// cell.css("background-color", "red");
}
},
eventOverlap: false, // will cause the event to take up entire resource height
resourceAreaWidth: '30%',
resourceColumns: [
{
labelText: 'Room',
field: 'title'
},
{
labelText: 'Occupancy',
field: 'occupancy'
}
],
resourceOrder: 'title', // when occupancy tied, order by title //-occupancy,title
resources: [
{ id: 'a', title: 'Room A', occupancy: 40 },
{ id: 'b', title: 'Room B', occupancy: 40, eventColor: 'green' },
{ id: 'c', title: 'Room C', occupancy: 40, eventColor: 'orange' },
{ id: 'd', title: 'Room D', occupancy: 40 },
{ id: 'e', title: 'Room E', occupancy: 40 },
{ id: 'f', title: 'Room F', occupancy: 40, eventColor: 'red' },
{ id: 'g', title: 'Room G', occupancy: 40 },
{ id: 'h', title: 'Room H', occupancy: 40 },
{ id: 'i', title: 'Room I', occupancy: 50 },
{ id: 'j', title: 'Room J', occupancy: 50 },
{ id: 'k', title: 'Room K', occupancy: 40 },
{ id: 'l', title: 'Room L', occupancy: 40 },
{ id: 'm', title: 'Room M', occupancy: 40 }
],
selectable: true,
selectHelper: true,
select: function(start, end, allDay, event, resourceId) {
var oldDay = new Date(start);
var toDay = new Date();
Date.prototype.sameDay = function(d) {
return this.getFullYear() === d.getFullYear()
&& this.getDate() === d.getDate()
&& this.getMonth() === d.getMonth();
}
if(oldDay.sameDay(toDay)) {
console.log('event select oldDay.sameDay');
createEvent(start,end,resourceId.id);
}else{
if(oldDay > toDay){
console.log('event select oldDay > toDay');
createEvent(start,end,resourceId.id);
}else{
alert("Cannot book for past days!");
}
}
},
eventClick: function(event, delta, revertFunc, jsEvent, ui, view ) {
console.log('eventClick');
//modifyEvent(event,'form');
},
eventMouseover: function(calEvent, jsEvent) {
var tooltip = '<div class="tooltipevent" title= "' + calEvent.title + '" style="width:100px;height:50px;background:#ccc;position:absolute;z-index:10001;">' + calEvent.title + '</div>';
$("body").append(tooltip);
$(this).mouseover(function(e) {
$(this).css('z-index', 10000);
$('.tooltipevent').fadeIn('500');
$('.tooltipevent').fadeTo('10', 1.9);
}).mousemove(function(e) {
$('.tooltipevent').css('top', e.pageY + 10);
$('.tooltipevent').css('left', e.pageX + 20);
});
},
eventMouseout: function(calEvent, jsEvent) {
$(this).css('z-index', 8);
$('.tooltipevent').remove();
},
eventDragStart : function( event,jsEvent ) {
console.log(jsEvent);
$(this).addClass('somthing');
$('.somthing').css("background-color", "yellow");
eventDateStart =event.start.format('YYYY-MM-DD');
eventDateEnd =event.end.format('YYYY-MM-DD');
eventStatus = event.status;
},
eventDrop: function(event, delta, revertFunc) {
console.log('eventDrop');
var now = new Date();
now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
var todayStart = event.start;
var todayEnd = event.end;
console.log('eventDragStart: '+eventDateStart+'---eventDateEnd: '+eventDateEnd+'----now: '+now+'----todayStart: '+todayStart.format('YYYY-MM-DD')+'---todayEnd: '+todayEnd.format('YYYY-MM-DD'));
if(eventStatus == 1){
alert("Guest has checked out, can't modify'");
revertFunc();
}else if( todayStart.format('YYYY-MM-DD') < now ){
alert("can't change room less than today date");
revertFunc();
}else if(todayEnd.format('YYYY-MM-DD') < now ){
alert("can't change room less than today date");
revertFunc();
}else{
if (confirm("Are you sure want to modify "+event.title + "Room Details?")) {
moveEvent(event);
}else{
revertFunc();
}
}
},
eventResizeStart : function (event, delta, revertFunc, jsEvent, ui, view ){
console.log('eventResizeStart');
eventDateStart =event.start.format();
eventDateEnd =event.end.format();
eventStatus = event.status;
},
eventResize: function (event, delta, revertFunc, jsEvent, ui, view ) {
var now = new Date();
now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
console.log('eventResize');
var todayStart = event.start;
var todayEnd = event.end;
if(eventStatus == 1){
alert("Guest has checked out, can't modify'");
revertFunc();
}else if(todayStart.format("YYYY-MM-DD") < now){
alert("can't change room less than today date");
revertFunc();
}else{
if (confirm("Are you sure want to modify "+event.title + "Room Details?")) {
modifyEvent(event,'resize');
}else{
revertFunc();
}
}
}
});
</script>
观点:{ timelineDay:{ 类型:'timeline', 持续时间:{天:365} } }
这对我来说很好(我的要求是1年半)但是当我添加548个/月18天时它的装载时间只有几个月而不是几天
请在这里建议我
由于