我一直在阅读fullcalendar文档几个小时并检查所提供的演示,但我看不出这是否可能。
我目前正在通过Google日历获取活动,其中包含许多字段,例如:
{
"status": "confirmed",
"kind": "calendar#event",
"end": {
"dateTime": "2015-06-29T17: 00: 00+02: 00"
},
"created": "2015-06-27T15: 29: 09.000Z",
"iCalUID": "grmb2ff27hh4ppvk0o7lfclimc@google.com",
"reminders": {
"useDefault": "True"
},
"htmlLink": "https: //www.google.com/calendar/event?eid=Z3JtYjJmZjI3aGg0cHB2azBvN2xmY2xpbWMgZGV2LmFsZWphbmRyb3ZpbGxhbWFyaW5AbQ",
"sequence": 0,
"updated": "2015-06-27T15: 29: 11.144Z",
"summary": "flowerpower",
"start": {
"dateTime": "2015-06-29T14: 00: 00+02: 00"
},
"etag": "2870837902288000",
"organizer": {
"self": "True",
"displayName": "AlejandroVillamarin",
"email": "dev.alejandrovillamarin@gmail.com"
},
"creator": {
"self": "True",
"displayName": "AlejandroVillamarin",
"email": "dev.alejandrovillamarin@gmail.com"
},
"id": "grmb2ff27hh4ppvk0o7lfclimc"
}
虽然我想保留这些数据,甚至通过ajax调用将其发送到fullcalendar,但我只想在日历中显示这些字段中的“一些”...我该怎么做?我总是可以使用2个数组,但看起来奇怪的是除了那个壮观的fullcalendar库之外没有提供自定义要在每个日历事件中显示的字段的方法。
谢谢, 亚历
答案 0 :(得分:1)
我一直使用FullCalendar eventRender event和jQuery来控制这些事情。
以下是我最近的一个项目的例子:
$(targetElement).fullCalendar({
events: function (start, end, callback) {
// code to grab events
},
eventRender: function (event, element) {
// 'event' will have all the fields that you want
// add css class 'label' and display status of event
element.find('.fc-event-title').addClass('label').append('STATUS ' + event.status);
var view = $(targetElement).fullCalendar('getView');
if (view.name === "agendaDay") {
// day view specific stuff here
}
if (view.name === "agendaWeek") {
// week view specific stuff here
}
}
});
我将这种数据附加与title property of an event一起使用。