简体   繁体   English

在本月的月份视图中的错误日期中全日历显示事件

[英]fullcalendar displaying event in the wrong day in month view of current month

在此处输入图片说明

I'm having an issue with my fullcalendar plug-in. 我的全日历插件有问题。 I'm currently trying to display events in the monthview of the calendar. 我目前正在尝试在日历的monthview中显示事件。 When i'm in the current month, the events that are on same day of the week are not displayed properly. 当我在当前月份时,一周中同一天的事件无法正确显示。 They will display in the sunday block of the same week. 它们将显示在同一周的星期天块中。 As you can see in the picture, i was holing the '4' event and it's written to be on the 13th, but displaying in the 8th. 正如您在图片中所看到的,我正在对'4'事件进行钻孔,它写在第13位,但在第8位显示。 Even the drag and drop knows that it's not in the right plate and there is the gray section underneath. 甚至拖放操作都知道它不在右面板中,并且在下面有灰色部分。 This is only happening when it's the current month. 仅在当前月份时才发生这种情况。 Last time I worked on my program, it was Tuesday and the tuesday events of november weren't appearing properly. 上一次我编写程序的时间是星期二,而11月的星期二活动未正确显示。

在此处输入图片说明

If i go into another month, every day will be displayed properly. 如果我再过一个月,则每天都会正确显示。 Anyone has an idea as of why my current month events render like this ? 有谁知道为什么我本月的活动如此呈现? This is my fullcalendar code. 这是我的完整日历代码。 I'm programming in ASP.NET with javascript and json for event rendering. 我正在使用JavaScript和json在ASP.NET中进行事件渲染的编程。

$('#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' }
            });

This is the json data rendered : 这是呈现的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}]

This is the function to render the event list : 这是呈现事件列表的功能:

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);
    }

I have been able to fix the problem by commenting the code below in the fullcalendar.js code. 我已经能够通过在fullcalendar.js代码中注释以下代码来解决此问题。 Friday events are now displaying in the friday column. 星期五活动现在显示在星期五列中。 Though, I don't believe that this is the best solution. 虽然,我不认为这是最好的解决方案。

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM