我正在使用FullCalendar 3.9.0版。我有一个问题。事件不会在MVC中呈现JsonResult的结果。我使用javascript:$('#calendar').fullCalendar('clientEvents');
进行了检查,但没有返回任何长度。但是,当我使用$.ajax
时,它将返回两个数组,如下所示:[{"id":5275,"title":"Test Image","start":"23/08/2018 16:39:47","end":"26/08/2018 16:39:47","backgroundColor":"#17a2b8"},{"id":5276,"title":"Test video","start":"23/08/2018 16:39:47","end":"26/08/2018 16:39:47","backgroundColor":"#17a2b8"}]
FullCalendar的配置:
$('#calendar').fullCalendar({
defaultView: 'basicWeek',
themeSystem: 'bootstrap4',
editable: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay,listWeek'
},
events: {
url: '/Schedule/TrinhChieuSchedule',
type: 'POST',
data: model
},
success: function(data) {
console.log(data);
},
error: function(err) {
AlertMessageDefaultPosition(err, "warning");
console.log(err);
},
});
这是MVC中的JsonResult:
public JsonResult TrinhChieuSchedule(ScheduleJsonModel model)
{
DateTime? ngayBatDau = null;
DateTime? ngayKetThuc = null;
if (!String.IsNullOrEmpty(model.ngayBatDau))
ngayBatDau = DateTime.Parse(model.ngayBatDau);
if (!String.IsNullOrEmpty(model.ngayKetThuc))
ngayKetThuc = DateTime.Parse(model.ngayKetThuc);
var list = db.SPC_SP_TrinhChieuSchedule(model.madv, ngayBatDau, ngayKetThuc);
var serializer = new JavaScriptSerializer();
var jsonString = serializer.Serialize(list.ToArray());
return Json(jsonString);
}
答案 0 :(得分:0)
我找到了解决此问题的方法。只需将日期格式更改为FullCalendar标准"YYYY-MM-DDThh:mm:ss"