We are using fullcalendar with .net core- ef core. We are getting all the event data by passing it to fullcalendar.That means a lot of event.Then It creates event calendar with theese data default by this month. What I want is make it lazy. When getting data, it would returns only events giving month.
in c#
public JsonResult GetEvents(E_Model model){
var list = _Service.GetEvents().ToList();
}
in js ajax calling file
function GetEvents() {
var events = [];
$.ajax({
type: "POST",
url: "/calHome/GetEvents",
data: { model: data },
success: function (data) {
calender.style.display = 'block';
$.each(data, function (i, v) {
events.push({
id: v.id,
title: v.name,
description: v.description,
//i got start and end moment
start: moment(v.start),
end: v.end != null ? moment(v.end) : null,});
})
GenerateCalender(events);
}
Generate calendar
function GenerateCalender(events) {
$('#calender').fullCalendar('destroy');
$('#calender').fullCalendar({
contentHeight: 800,
firstDay: 1,
defaultDate: new Date(),
timeFormat: 'HH:mm',
eventLimit: true,
events: events,
}
ajax GetEvents calls GetEvents in controller it returns json then GetEvents in ajax calls genaretecalendar. When Calling the GetEvents metod in aja. I want to make it when I press the prev or next button, it will give the month to controller and get data by month. I tryed to listen prev event like
$('.fc-prev-button').one('click',function (e) {
console.log('prev, do something');
});
NEW
events: {
type: "POST",
url: "/home/GetEvents",
data: function () { // a function that returns an object
return {
};
}
Controller
[HttpPost]
public JsonResult GetEvents(FiltModel model)
//model includes string start, end