引导程序完整日历能容纳的数据量最大吗。它似乎在525个条目后崩溃。它一直工作得很好,直到达到这个极限。
它抛出了一个错误:
Error: {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}
我正在动态绑定我的数据。
<script type="text/javascript">
$(document).ready(function () {
var events = [];
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
url: "Dashboard.aspx/GetEvents",
success: function (data) {
$.each(data.d, function (i, v) {
events.push({
title: v.Title,
start: moment(v.VCStartTime),
end: v.VCEndTime != null ? moment(v.VCEndTime) : null
});
})
GenerateCalendar(events);//binds data to calendar
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + XMLHttpRequest.responseText);
}
//error: function (error) {
// alert('failed');
//}
})
用于获取数据的Asp.net代码
[WebMethod]
public static List<events> GetEvents()
{
DataSet ds = new APIProcedure().ByProcedure("calendar_sp", new string[] { "key" },
new string[] { "getvalueForCalendar" }, "USPADDSETTING");
return ds.Tables[0].AsEnumerable().Select(datarow =>
new events()
{
Id = Convert.ToInt32(datarow["Id"]),
Title = Convert.ToString(datarow["Title"]),
Date = Convert.ToDateTime(datarow["Date"]),
StartTime = Convert.ToDateTime(datarow["StartTime"]),
EndTime = Convert.ToDateTime(datarow["EndTime"]),
}
).ToList();
}
public class events
{
public int Id { get; set; }
public string Title { get; set; }
public DateTime Date { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
$(document).ready(function () {
$('#calendar').fullCalendar({
contentHeight: 400,
defaultDate: new Date(),
timeFormat: 'h(:mm)a',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
eventLimit: true,
eventColor: '#87c9f0',
events: function (start, end, timezone, callback) {//instead of getting all the data at once get data for visible part of calendar.
var Date1 = new Date(start);
let newdate = JSON.stringify(Date1);
newStartdate = newdate.slice(1, 11);
var Date2 = new Date(end);
let newdate2 = JSON.stringify(Date2);
newEnddate = newdate2.slice(1, 11);
$.ajax({
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: "{ 'StartDate': '" + newStartdate + "', 'EndDate': '" + newEnddate + "' }",//send data to code behind and get data according to start and end date
url: "Dashboard.aspx/GetEvents",
success: function (data) {
var events = [];
$.each(data.d, function (i, v) {
events.push({
title: v.Title,
start: moment(v.VCStartTime),
end: v.VCEndTime != null ? moment(v.VCEndTime) : null
});
})
callback(events);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + XMLHttpRequest.responseText);
}
})
}