在周视图fullcalendar中显示事件

时间:2013-03-15 09:17:54

标签: jquery jquery-ui fullcalendar

这里显示的是fullcalender中的事件。

但是来到周视图时事件不会在事件时间显示。

此处测试活动时间为上午10:00至中午12:00。但事件正在最高层展示。

function DisplayCalendar() {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        data: "{}",
        url: "Events.aspx/GetEvents",
        dataType: "json",
        success: function(data) {
            var date = new Date();
            var d = date.getDate();
            var m = date.getMonth();
            var y = date.getFullYear();
            $('div[id*=calendar]').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                select: selectDate,
                eventClick: updateEvent,
                editable: true,
                droppable: false,
                draggable: false,
                disableDragging: true,
                selectable: true,
                selectHelper: true,
                eventTextColor: 'Yellow',
                eventBackgroundColor: 'purple',
                eventRender: function(event, element) {
                    var view = $('#calendar').fullCalendar('getView');
                    if (view.name == 'agendaWeek') {
                        //alert(view.visStart);
                    }
                    //return false;
                },
                events: $.map(data.d, function(item, i) {
                    var sdate = item.StartDate;
                    var sdatesplit = sdate.split("/");
                    var sm = sdatesplit[0];
                    var sd = sdatesplit[1];
                    var sy = sdatesplit[2];
                    var syearsplit = sy.split(" ");

                    var edate = item.EndDate;
                    var edatesplit = edate.split("/");
                    var em = edatesplit[0];
                    var ed = edatesplit[1];
                    var ey = edatesplit[2];
                    var eyearsplit = ey.split(" ");
                    var event = new Object();
                    event.id = item.EventID;
                    event.start = new Date(syearsplit[0], sm, sd, 16, 0);
                    event.end = new Date(eyearsplit[0], em, ed, 18, 0);
                    event.title = item.EventName;
                    event.allDay = true;
                    return event;
                    //event.id= item.EventID;
                    //event.title= item.EventName;
                    //event.start= new Date(y, m, d, 16, 0);
                    //event.end= new Date(y, m, d, 16, 30);
                    //event.allDay= true;
                    //return event;
                })
            });
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            debugger;
        }
});

1 个答案:

答案 0 :(得分:0)

Fullcalendar会在顶部显示事件,因为您为事件设置了“allDay”属性:

event.allDay = true;

检查fullcalendar documentation是否有allDay属性:

  

此外,在议程视图中,确定它是否显示在“全天”部分中。