Javascript 将FullCalendar事件填充为数组-从另一个数组填充

Javascript 将FullCalendar事件填充为数组-从另一个数组填充,javascript,jquery,fullcalendar,Javascript,Jquery,Fullcalendar,我对JS很陌生。我对web服务的调用返回如下数组: data {...} [0]: {...} [1]: {...} [2]: {...} [3]: {...} length: 4 data[0] {...} __type: "acme.acmeSystem.EventManagement.Event" Amenity: {...} DateFrom: "/Date(1326952800000)/" DateTo

我对JS很陌生。我对web服务的调用返回如下数组:

data {...}
    [0]: {...}
    [1]: {...}
    [2]: {...}
    [3]: {...}
    length: 4 

    data[0] {...}
    __type: "acme.acmeSystem.EventManagement.Event"
    Amenity: {...}
    DateFrom: "/Date(1326952800000)/"
    DateTo: "/Date(1326952800000)/"
    Description: "Friends coming over for a party."
    Food: false
    Id: 3
    IsPrivate: true
    Notes: ""
    NumberOfPeople: "Less than 10"
    Status: {...}
    TimeFrom: "8:30 AM"
    TimeTo: "11:30 AM"
    User: {...}
GetEvents([], false,
    {
        successCallback: function (data) {
            if ((data) && (data != null) && (data.length > 0)) {

                buildingEvents = data;                  

                $('#calendar').fullCalendar({
                    theme: true,
                    header: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay'
                    },
                    editable: false,
                    events: buildingEvents
                });

            }

            data = null;
        }
    });
如何将其插入完整日历

我正在尝试这样的事情:

data {...}
    [0]: {...}
    [1]: {...}
    [2]: {...}
    [3]: {...}
    length: 4 

    data[0] {...}
    __type: "acme.acmeSystem.EventManagement.Event"
    Amenity: {...}
    DateFrom: "/Date(1326952800000)/"
    DateTo: "/Date(1326952800000)/"
    Description: "Friends coming over for a party."
    Food: false
    Id: 3
    IsPrivate: true
    Notes: ""
    NumberOfPeople: "Less than 10"
    Status: {...}
    TimeFrom: "8:30 AM"
    TimeTo: "11:30 AM"
    User: {...}
GetEvents([], false,
    {
        successCallback: function (data) {
            if ((data) && (data != null) && (data.length > 0)) {

                buildingEvents = data;                  

                $('#calendar').fullCalendar({
                    theme: true,
                    header: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay'
                    },
                    editable: false,
                    events: buildingEvents
                });

            }

            data = null;
        }
    });
我需要从building events数组中创建另一个FullCalendar事件数组:

比如:

$('#calendar').fullCalendar({
    events: [
        {
            title  : 'event1',
            start  : '2010-01-01'
        },
        {
            title  : 'event2',
            start  : '2010-01-05',
            end    : '2010-01-07'
        },
        {
            title  : 'event3',
            start  : '2010-01-09 12:30:00',
            allDay : false // will make the time show
        }
    ]
});

谢谢。

我想您可以使用jquery函数

jQuery.map(数组,回调(elementOfArray,indexInArray))返回:array
描述:将数组或对象中的所有项转换为新的项数组

基本上,您可以将从服务器接收的数据映射到一系列EventData对象中,这些对象可以被fullCalendar理解:

var buildingEvents = $.map(data, function(item) {
    return {
        id: item.Id,
        title: item.Description,
        start: ... // "bind" all properties as needed
    };
});

非常感谢你!!!成功了。只是想进行更正(冒号而不是=),因此,var buildingEvents=$.map(数据,函数(项){return{id:item.id,title:item.Description,start:…/“绑定”所有需要的属性};});在这里可以找到这种实现的第二个参考:这个问题对我很有帮助。谢谢