2

我想使用 fullcalendar 创建一个学校时间表。

它应该看起来像这样: 链接

我的问题是 fullcalendar 总是在工作日旁边显示日期。(“周三 - 04/27”,“周四 - 04/28”,...)

我想要的是只有周一到周五,没有日期,也没有机会切换到下周。这应该是一个抽象的一周。有没有办法做到这一点?

谢谢你的帮助。

4

1 回答 1

3

在使用了您可以在文档中找到的插件的所有功能之后,我有一个工作日历!

这是它的样子: 全日历

这是代码:

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 文件,该文件返回所有事件对象(参见下面的代码)。可以使用操作执行拖放操作(如上面的代码所示)。

事件.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);

 ?>
于 2016-04-27T09:56:00.657 回答