我想使用fullcalendar创建学校时间表。
看起来应该是这样的: Link
我的问题是fullcalendar总是显示工作日旁边的日期。 (“Wed - 04/27”,“Thu - 04/28”,...)
我想要的是周一至周五没有日期,也没有机会切换到下周。它应该是一个抽象的星期。 有没有办法实现这个目标?
感谢您的帮助。
答案 0 :(得分:2)
在使用docs中可以找到的插件的所有功能后,我有一个工作日历!
以下是代码:
var calendar = $('#trainingszeitenCalendar').fullCalendar({
//lang: 'de',
header: { // Display nothing at the top
left: '',
center: '',
right: ''
},
eventSources: ['events.php'],
height: 680, // Fix height
columnFormat: 'dddd', // Display just full length of weekday, without dates
defaultView: 'agendaWeek', // display week view
hiddenDays: [0,6], // hide Saturday and Sunday
weekNumbers: false, // don't show week numbers
minTime: '16:00:00', // display from 16 to
maxTime: '23:00:00', // 23
slotDuration: '00:15:00', // 15 minutes for each row
allDaySlot: false, // don't show "all day" at the top
select: function(start, end, allDay) {
// Code for creating new events.
alert("Create new event at " + start);
},
eventResize: function( event, delta, revertFunc, jsEvent, ui, view ) {
// Code when you resize an event (for example make it two hours longer
alert("I just got resized!");
},
eventDrop: function( event, jsEvent, ui, view ) {
// Code when you drop an element somewhere else
alert("I'm somewhere else now");
}
}
// With the next line I set a fixed date for the calendar to show. So for the user it looks like it's just a general week without a 'real' date behind it.
$('#trainingszeitenCalendar').fullCalendar( 'gotoDate', '2000-01-01');
修改强>
我创建了一个包含不同事件的MYSQL表。事件介于1999-12-27
和2000-01-02
之间。
要将事件添加到表中,您需要一个单独的php文件,它返回所有事件对象(请参阅下面的代码)。
可以使用操作执行拖放操作(如上面的代码所示)。
<强> events.php 强>
<?php
$fetch = "YOUR SQL Statement";
$query = mysqli_query....; // Execute fetch
$event_array = array();
while ($event = mysqli_fetch_array($query, MYSQL_ASSOC)) {
$id = $event['ID'];
$title = $event['Title'];
$description = $event['Description'];
$startdatum = $event['Start'];
$enddatum = $event['Ende'];
// Add event object to JSON array
// For more options check the fullcalendar.io docs
$event_array[] = array(
'id' => $id,
'title' => $title,
'description' => $description,
'start' => $startdatum,
'end' => $enddatum
);
}
echo json_encode($event_array);
?>