我想知道,是否可以用以下格式用FullCalendar创建日历:
我以日期形式形成了reusers。但是我只在一天之内看到事件。可以纠正事件。但是也许可以用这种格式显示所有日期。
提前谢谢!
我暂时通过以下方式解决了这个问题:
<div class="panel-body">
<div id="calendar"></div>
</div>
@section Styles {
<link href="~/lib/fullcalendar/dist/fullcalendar.min.css" rel="stylesheet" />
<link href="~/lib/fullcalendar-scheduler/dist/scheduler.min.css" rel="stylesheet" />
}
@section Scripts {
<script src="~/lib/moment/moment.js"></script>
<script src="~/lib/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="~/lib/fullcalendar/dist/locale/ru.js"></script>
<script src="~/lib/fullcalendar-scheduler/dist/scheduler.min.js"></script>
<script>
$(function () {
$('#calendar').fullCalendar({
defaultView: 'timelineDay',
slotDuration: '00:30',
slotWidth: 5,
height: 'auto',
eventOverlap: false,
nowIndicator: true,
businessHours: true,
defaultDate: "@DateTime.Now.ToString("yyyy-MM")-01",
titleFormat: 'MMMM YYYY',
header: {
left: 'myPrevButton,myNextButton',
center: 'title',
right: ''
},
customButtons: {
myNextButton: {
//text: 'Next',
icon: 'right-single-arrow',
click: function () {
$('#calendar').fullCalendar('incrementDate', {
months: 1,
});
$('#calendar').fullCalendar('refetchResources');
}
},
myPrevButton: {
//text: 'Prev',
icon: 'left-single-arrow',
click: function () {
$('#calendar').fullCalendar('incrementDate', {
months: -1,
});
$('#calendar').fullCalendar('refetchResources');
}
}
},
events: "/api/Sheduling/eventpersonal/@Model.Id",
refetchResourcesOnNavigate: true,
resources: '/api/Sheduling/1'
});
});
</script>
}
此解决方案对我有用。但这需要多余的操作。 这个解决方案对我有用。但这需要多余的操作。我收到以下形式的一名员工的时间表:
资源:
[{"id":1,"title":"1/8"},{"id":2,"title":"2/8"},{"id":3,"title":"3/8"},{"id":4,"title":"4/8"},{"id":5,"title":"5/8"},{"id":6,"title":"6/8"}, ....
事件(所有开始于结束日期的事件是该月的第一天,而resourceId是该月的日期):
[{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T10:05:00","end":"2018-08-01T10:09:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T10:35:00","end":"2018-08-01T10:39:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T11:05:00","end":"2018-08-01T11:09:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T11:35:00","end":"2018-08-01T11:39:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T12:05:00","end":"2018-08-01T12:09:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T12:35:00","end":"2018-08-01T12:39:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T13:05:00","end":"2018-08-01T13:09:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T13:35:00","end":"2018-08-01T13:39:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T14:05:00","end":"2018-08-01T14:09:50"},{"color":"#006633","id":1,"resourceId":1,"start":"2018-08-01T14:35:00","end":"2018-08-01T14:39:50"}, ....