带有彩色事件的Jquery fullcalendar



我是新的查询,我有一个问题与fullcalendar (http://arshaw.com/fullcalendar/)。我想根据事件的类型给它们上色。

js:

    $(document).ready(function () {
        $('#fullcal').fullCalendar({
            allDayDefault: false,
            defaultView: 'agendaWeek',
            eventSources: [
                {
                    url: 'WS.asmx/GetSchedulerEvents',
                    type: 'POST',
                    data: {
                        taskType: 'TODO'
                    },
                    color: 'red',
                    textColor: 'black'
                },
                {
                    url: 'WS.asmx/GetSchedulerEvents',
                    type: 'POST',
                    data: {
                        taskType: 'COMPLETED'
                    },
                    color: 'blue',
                    textColor: 'white'
                }
            ]
        })
    });

webservice方法:

    [WebMethod]
    public List<SchedulerEvent> GetSchedulerEvents(string taskType)
    {
        List<SchedulerEvent> events = new List<SchedulerEvent>();
        if (taskType == "TODO")
        {
            events.Add(new SchedulerEvent(
                2,
                "EventName 1",
                new DateTime(2013, 05, 20, 10, 00, 00).ToString(),
                new DateTime(2013, 05, 20, 10, 00, 00).AddHours(4).ToString()
            ));
        }
        else if (taskType == "COMPLETED")
        {
            events.Add(new SchedulerEvent(
                 1,
                 "EventName 2",
                 new DateTime(2013, 05, 21, 11, 00, 00).ToString(),
                 new DateTime(2013, 05, 21, 11, 00, 00).AddHours(3).ToString()
             ));
        }
        return events;
    }
请求:

taskType=TODO&start=1368914400&end=1369519200
and
taskType=COMPLETED&start=1368914400&end=1369519200

反应:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSchedulerEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
  <SchedulerEvent>
    <EventId>1</EventId>
    <EventName>EventName 2</EventName>
    <StartDate>2013-05-21 11:00:00</StartDate>
    <EndDate>2013-05-21 14:00:00</EndDate>
  </SchedulerEvent>
</ArrayOfSchedulerEvent>
and
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSchedulerEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
  <SchedulerEvent>
    <EventId>2</EventId>
    <EventName>EventName 1</EventName>
    <StartDate>2013-05-20 10:00:00</StartDate>
    <EndDate>2013-05-20 14:00:00</EndDate>
  </SchedulerEvent>
</ArrayOfSchedulerEvent>

我的问题是:为什么请求和响应不是json格式?

谢谢

Fullcalendar的正确JSON格式是这样的:

    JSON FORMAT FEED
 [
{
    "title" : "New shift",
    "start" : "2010-10-25 09: 30: 00 +0100",
    "end" : "2010-10-25 13: 30: 00 +0100",
    "allDay" : false 
},
{
    "title" : "New shift",
    "start" : "2010-10-25 08: 00: 00 +0100",
    "end" : "2010-10-25 14: 00: 00 +0100",
    "allDay" : false 
},
{
    "title" : "New shift",
    "start" : "2010-10-25 08: 00: 00 +0100",
    "end" : "2010-10-25 14: 00: 00 +0100",
    "allDay" : false 
},
{
    "title" : "New shift",
    "start" : "2010-10-27 08: 00: 00 +0100",
    "end" : "2010-10-27 13: 30: 00 +0100",
    "allDay" : false 
} 
 ]

这是另一个问题,我不记得是哪一个了,所以也许它可以帮助你检查你的

相关内容

  • 没有找到相关文章

最新更新