0

我是新来的查询,我对 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'
                }
            ]
        })
    });

网络服务方法:

    [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 格式?

谢谢

4

1 回答 1

0

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 
} 
 ]

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

于 2013-05-21T21:18:03.957 回答