数据存储模型Model:
复制代码 代码如下:
public class CalendarEvent
{
public string id { get; set; }
public DateTime start { get; set; }
public DateTime end { get; set; }
public string backgroundColor { get; set; }
public string title { get; set; }
public string allDay { get; set; }
}
前台接收显示数据视图View:
复制代码 代码如下:
<script type="text/javascript">
$(function () {
//calendar handle data as follows:
var events = [];
$.ajax({
url: "/DeploymentTask/CalendarData",
success: function (data) {
events = data;
},
async: false
});
$("#calendar").fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
//right: 'month,agendaWeek,agendaDay'
right: 'month'
},
selectable: true,
weekMode: 'variable',//fixed,variable,liquid
events: events,
defaultEventMinutes: 1440 //默认事件长度为一天
});
});
</script>
后台处理数据控制器Controller:
复制代码 代码如下:
public JsonResult CalendarData()
{
Operation op = new Operation();
List<CalendarEvent> calendarData = op.GetData();
return Json(calendarData, JsonRequestBehavior.AllowGet);
}