仅显示 fullcalendar.io 中当月的日期和事件

Show days and events only of the current month in the fullcalendar.io

本文关键字:日期 事件 显示 fullcalendar io      更新时间:2023-09-26

在 fullcalendar.io 的"月"视图中,我只想显示当前月份,以及当前月份的事件。但是,目前显示的是自当前日期开始计算的月份。

例如:如果今天的日期是 2016-20-03...
- 什么全日历显示: 从: 2016-20-03 至: 2016-19-04
- 我想展示的内容: 从 2016-01-03 到: 2016-31-03

阅读文档并四处查找后,我找不到任何变量或为完整日历设置来实现这一点,因此我将不得不修改完整日历.js

有人已经这样做了吗?

视图

$('#' + engineerId).fullCalendar({
            header: false,
            views: {
                plainMonth: {
                    type: 'basic',
                    duration: { days: 31 },
                    buttonText: 'Month'
                },
                plainWeek: {
                    type: 'basic',
                    duration: { days: 7 },
                    buttonText: 'Week'
                }
            },
            firstDay: 1,
            dayNamesShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
            defaultView: 'plainWeek',
            theme: true,
            viewRender: function (view, element) {
                $('#CalendarViewObject').val(view.name);
                viewName = view.name;
            },
            aspectRatio: ratio,
            editable: true,
            eventLimit: false, // allow "more" link when too many events
            events: {
                startEditable: false,
                durationEditable: false,
                url: window.location.href.toString().split(window.location.host)[1] + '/GetEmployeeEvents',
                type: 'POST',
                data: function () { // a function that returns an object
                    $("[id^=qtip-]").empty();
                    $("[id^=qtip-]").remove();
                    return {
                        serviceAreaId: serviceAreaId,
                        employeeId: engineerId,
                        calendarViewObject: $('#CalendarViewObject').val()
                    };
                },
                error: function () {
                    alert('there was an error while fetching events!');
                }
            },...

控制器

public JsonResult GetEmployeeEvents(DateTime start, DateTime end, string queueName, string employeeId, string calendarViewObject)
"

开始"和"结束"日期由 fullcalendar.io 设置,这些日期是我想更改的日期。

提前非常感谢你,阿尔维昆

在对完整日历文档进行了更多研究之后,我最终设置了以下内容:

$(''.calendarClass'').fullCalendar(''gotoDate'',new Date(y, m, 1));

这成功了,有效!