javascript - 全日历在当前月份的月 View 中的错误日期显示事件

标签 javascript asp.net json fullcalendar

enter image description here

我的 fullcalendar 插件遇到问题。我目前正在尝试在日历的月 View 中显示事件。当我在当前月份时,一周中同一天的事件无法正确显示。它们将显示在同一周的星期日区 block 中。正如你在图片中看到的,我正在打“4”事件,它写的是 13 号,但显示在 8 号。即使拖放也知道它不在正确的板中,并且下面有灰色部分。仅当当前月份时才会发生这种情况。上次我编写程序时是星期二,11 月的星期二事件没有正确显示。

enter image description here

如果我进入另一个月份,每一天都会正确显示。任何人都知道为什么我当前的月份事件呈现这样的情况?这是我的完整日历代码。我正在 ASP.NET 中使用 JavaScript 和 json 进行事件渲染编程。

$('#calendar').fullCalendar({
        theme: true,
        header: {
            right: 'today prev,next',
            left: 'title'
        },
        defaultView: 'month',
        eventClick: updateEvent,
        selectable: true,
        selectHelper: true,
        select: selectDate,
        timezone : 'local',
        editable: true,
        events: "../JsonResponse.ashx",
        eventDrop: eventDropped,
        eventResize: eventResized,
        eventRender: function (event, element) {
            //alert(event.title);
            element.qtip({
                content: {
                    text: qTipText(event.start, event.end),
                    title: '<strong>' + event.title + '</strong>'
                },
                position: {
                    my: 'bottom left',
                    at: 'top right'
                },
                style: { classes: 'qtip-dark qtip-rounded' }
            });

这是呈现的 json 数据:

   [{"id":27,"title":"2.5","start":"2015-11-28T00:00:00","end":"2015-11-29T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":43,"title":"5","start":"2015-11-18T00:00:00","end":"2015-11-19T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":44,"title":"5.6","start":"2015-12-03T00:00:00","end":"2015-12-04T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":45,"title":"8","start":"2015-11-12T00:00:00","end":"2015-11-13T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":46,"title":"5","start":"2015-11-16T00:00:00","end":"2015-11-17T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":47,"title":"9","start":"2015-11-27T00:00:00","end":"2015-11-28T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":55,"title":"1","start":"2015-11-06T00:00:00","end":"2015-11-07T00:00:00","allDay":true,"id_projet":68,"id_employe":1},{"id":56,"title":"7","start":"2015-11-29T00:00:00","end":"2015-11-30T00:00:00","allDay":true,"id_projet":68,"id_employe":1}]

这是呈现事件列表的函数:

public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        // FullCalendar 2.x
        DateTime start = Convert.ToDateTime(context.Request.QueryString["start"]);
        DateTime end = Convert.ToDateTime(context.Request.QueryString["end"]);
        int id_employe = Int32.Parse(context.Session["id_employe"].ToString());
        int id_projet = Int32.Parse(context.Session["id_projet"].ToString());


        List<int> idList = new List<int>();
        List<ImproperCalendarEvent> tasksList = new List<ImproperCalendarEvent>();

        //Generate JSON serializable events
        foreach (CalendarEvent cevent in EventDAO.getEvents(start, end, id_projet, id_employe))
        {
            tasksList.Add(new ImproperCalendarEvent
            {
                id = cevent.id,
                title = cevent.title,
                id_projet = cevent.id_projet,
                id_employe = cevent.id_employe,

                // FullCalendar 2.x
                start = String.Format("{0:s}", cevent.start),
                end = String.Format("{0:s}", cevent.end),
                allDay = true,
            }
                );

                idList.Add(cevent.id);    

        }

        context.Session["idList"] = idList;

        //Serialize events to string
        System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        string sJSON = oSerializer.Serialize(tasksList);

        //Write JSON to response object
        context.Response.Write(sJSON);
    }

最佳答案

我已经能够通过在 fullcalendar.js 代码中注释下面的代码来解决该问题。周五事件现在显示在周五专栏中。不过,我不认为这是最好的解决方案。

enter image description here

enter image description here

关于javascript - 全日历在当前月份的月 View 中的错误日期显示事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33576241/

相关文章:

asp.net - 当多个用户从 asp 成员(member)身份登录时,如何将用户名放入 sql 触发器中

Asp.Net MVC ActionLink

json - 使用 java Mapreduce 处理 JSON

php - 在 PHP 中通过 JSON API 获取 Youtube 订阅者数量

ios - Swift iOS API Controller 停止工作

javascript - 拖放文本练习

javascript - get 函数无法与 JSON 字符串中的本地存储正常工作

.net - 关于.NET 中接口(interface)继承的问题

循环内的 Javascript 变量声明

javascript - let in 回调函数的作用域,需要了解