实际上我试图在fullcalendar上显示事件(json feed)。如何在fullcalendar视图中显示我的json响应事件。
继承我的控制器代码:
public ActionResult GetEventWithSpecifiedDate(string start, string end)
{
var newEvent = new List<CalendarEventModel>();
newEvent.Add(new CalendarEventModel(){
id = 1,
start = DateTime.Now.ToString("yyyy-MM-dd HH:mm"),
end = DateTime.Now.AddDays(2).ToString("yyyy-MM-dd HH:mm"),
title = " it works",
});
newEvent.Add(new CalendarEventModel(){
id = 2,
start = DateTime.Now.AddDays(4).ToString("yyyy-MM-dd HH:mm:ffff"),
end = DateTime.Now.AddDays(2).ToString("yyyy-MM-dd HH:mm:ffff"),
title = "really it works!",
});
return Json(new JsonResultModel() { success = true, aaData = newEvent }, JsonRequestBehavior.AllowGet);
}
以及我的js代码:
genericCalendar: function (id, ajaxSourceUrl, data, eventDataTransform, callbackFnc) {
$(id).fullCalendar('destroy');
$(id).fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
allDayDefault: false,
selectable: true,
selectHelper: true,
ignoreTimezone: false,
select: function (start, end, allDay) {
if (callbackFnc)
callbackFnc();
$(id).fullCalendar('refetchResources');
},
editable: true,
monthNames: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],
monthNamesShort: ["Ocak", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Ekim", "Kas", "Ara"],
dayNames: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"],
dayNamesShort: ["Pzr", "Pts", "Sal", "Çrş", "Prş", "Cum", "Cts"],
titleFormat: { month: "MMMM yyyy", week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}", day: " d MMM yyyy , dddd" },
eventDataTransform: function (eventData) {
if (eventDataTransform)
eventDataTransform(eventData);
return eventData;
},
events: function (start, end, callback) {
$.ajax({
type: 'POST',
url: ajaxSourceUrl,
data: {
start: start.toLocaleDateString(),
end: end.toLocaleDateString()
},
success: function (data) {
var events = [];
$.each(data, function (index, value) {
debugger;
events.push({
id: value['id'],
title: value['title'],
start: value['start'],
end: value['end']
});
});
console.log(index + ": " + value);
}
});
},
eventRender: function (calEvent, $event) {
calEvent.type //this is my new field
},
eventClick: function (event, element) {
if (callbackFnc)
callbackFnc(event, element);
$(id).fullCalendar('refetchResources');
}
});
},
如何在fullcalendar视图中显示我的json响应事件..我不能..
答案 0 :(得分:1)
如果我理解你的问题。
如docs
中所述<强> gotoDate 强>
将日历移动到任意日期。
.fullCalendar( 'gotoDate', date )
date
可以是Moment对象,也可以是Moment构造函数 接受。