[英]Jquery Full Calendar- Month name to be passed as a parameter to database when prev and next is clicked
Team, 球队,
I am new to jquery and C#. 我是jquery和C#的新手。 I am trying to integrate jquery Full calendar plugin with the code in C# to show leaves taken up by company resources.There are more than 10,000 records in the database which i would like to filter by fiscal year and fiscal month.So I would like to pass in the two parameters to the C# db code (year and month) when i click on prev and next buttons. 我正在尝试将jquery Full calendar插件与C#中的代码集成以显示公司资源占用的叶子。数据库中有10,000多个记录,我想按会计年度和会计月份进行筛选。当我单击上一个和下一个按钮时,将两个参数传递给C#数据库代码(年和月)。
I am able to display the first 500 rows from the db on the calendar( I guess i cannot display more than that--Seems a limitation) 我可以在日历上显示数据库的前500行(我想我不能显示更多,这似乎是一个限制)
Below is the code 下面是代码
js code js代码
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json",
data: "{}",
url: "CalendarPage.aspx/GetEvents",
dataType: "json",
success: function (data) {
$('div[id*=fullcal]').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: $.map(data.d, function (item, i) {
//var eventsUrl = '/events/' + end.year() + '/' + parseInt(end.month());
var event = new Object();
event.id = item.EventID;
event.start = new Date(item.StartDate);
event.end = new Date(item.EndDate);
event.title = item.EventName;
event.url = item.Url;
event.ImageType = item.ImageType;
return event;
}), eventRender: function (event, eventElement) {
if (event.ImageType) {
if (eventElement.find('span.fc-event-time').length) {
eventElement.find('span.fc-event-time').before($(GetImage(event.ImageType)));
} else {
eventElement.find('span.fc-event-title').before($(GetImage(event.ImageType)));
}
}
},
loading: function (bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
debugger;
}
});
$('#loading').hide();
$('div[id*=fullcal]').show();
});
function GetImage(type) {
if (type == 0) {
return "<br/><img src = 'Styles/Images/attendance.png' style='width:24px;height:24px'/><br/>"
}
else if (type == 1) {
return "<br/><img src = 'Styles/Images/not_available.png' style='width:24px;height:24px'/><br/>"
}
else
return "<br/><img src = 'Styles/Images/not_available.png' style='width:24px;height:24px'/><br/>"
}
</script>
C# code C#代码
[WebMethod]
public static IList GetEvents()
{
Leave_Management_Leave_TakenTableAdapter LTTA = new Leave_Management_Leave_TakenTableAdapter();
DB.Leave_Management_Leave_TakenDataTable LTTbl = null;
**LTTbl = LTTA.GetForCalendar("I wish to put the parameters here");**
IList events = new List<Event>();
foreach( DataRow dr in LTTbl.Rows)
{
events.Add(new Event
{
EventName = dr["Fullname"] + " Leave",
// DateTime dt = ,
StartDate = DateTime.Parse(dr["leave_days"].ToString()).ToString("MM-dd-yyyy")
});
}
return events;
}
Can anyone please suggest any changes ? 任何人都可以提出任何建议吗?
Fullcalendar passes 2 GET parameters anytime it makes a request for data, if you add (DateTime start, DateTime end) to your GetEvents method you can filter your data for the given range. Fullcalendar会在每次请求数据时传递2个GET参数,如果将(DateTime开始,DateTime结束)添加到GetEvents方法中,则可以过滤给定范围的数据。
https://fullcalendar.io/docs/event_data/events_json_feed/ https://fullcalendar.io/docs/event_data/events_json_feed/
I thought earlier that the control faced a limitation of populating around 700-800 event records on the calendar. 我早些时候以为控件面临着在日历上填充700-800个事件记录的局限性。 On further investigating, I stumbled on a piece of code to be placed in the web.config. 在进一步调查中,我偶然发现了放在web.config中的一段代码。 This basically maximizes the lenght of jsonserialization string. 这基本上可以最大化jsonserialization字符串的长度。
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000"/>
</webServices>
</scripting>
</system.web.extensions>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.