1、fullcalendar有一组自己的字段:id,start,end,title.其中start的时间也有格式。
一般都是因为这个原因,导致后台获取数据后,却在日历中显示不出来文字信息。
$.ajax({
type: "post",
url: "getCalendar",
dataType: "json",
data: {
start: startdate
},
success: function (data) {
var events = [];
$.each(data, function (i) {
events.push({
id: data[i].id,
title: data[i].title,
start: data[i].start,
end: data[i].end,
Cal_content: data[i].Cal_content
})
})
callback(events);
}
});
controller:
public ActionResult getCalendar(DateTime start)
{
DateTime etime = start.AddMonths(1).AddDays(-1);
Bll.BSP_RunLog brunlog = new Bll.BSP_RunLog();
var sportslst = brunlog.SelectCal((Guid)Session["UserID"], start, etime);
var lst = new List
if (sportslst.Count != 0)
{
for (int i = 0; i < sportslst.Count; i++)
{
lst.Add(new Model.calendarevent
{
id = i + 1,
start = sportslst[i].RunDate.ToString("yyyy-MM-dd") + " 08:30:00",
end = sportslst[i].RunDate.ToString("yyyy-MM-dd") + " 10:30:00",
title = "当日运动量",
Cal_content = "运动量为:" + sportslst[i].RunDistance.Tostring() + "公里"
});
}
}
return Json(lst, JsonRequestBehavior.AllowGet);
}