第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

.net core Fullcalendar 通過(guò)給定月份獲取數(shù)據(jù)

.net core Fullcalendar 通過(guò)給定月份獲取數(shù)據(jù)

動(dòng)漫人物 2023-09-28 16:51:27
我們將 fullcalendar 與 .net core-ef core 結(jié)合使用。我們通過(guò)將其傳遞到 fullcalendar 來(lái)獲取所有事件數(shù)據(jù)。這意味著有很多事件。然后它會(huì)在本月默認(rèn)使用這些數(shù)據(jù)創(chuàng)建事件日歷。我想要的是讓它變得懶惰。獲取數(shù)據(jù)時(shí),它只會(huì)返回給出月份的事件。在 c# 中public JsonResult GetEvents(E_Model model){     var list = _Service.GetEvents().ToList();   }在js ajax調(diào)用文件中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);}生成日歷function GenerateCalender(events) {    $('#calender').fullCalendar('destroy');    $('#calender').fullCalendar({        contentHeight: 800,        firstDay: 1,        defaultDate: new Date(),        timeFormat: 'HH:mm', eventLimit: true,        events: events,}ajax GetEvents 在控制器中調(diào)用 GetEvents,它返回 json,然后 ajax 中的 GetEvents 調(diào)用 genaretecalendar。在aja中調(diào)用GetEvents方法時(shí)。我想在按下上一個(gè)或下一個(gè)按鈕時(shí)做到這一點(diǎn),它將向控制器提供月份并按月獲取數(shù)據(jù)。我嘗試聽(tīng)上一個(gè)事件,例如$('.fc-prev-button').one('click',function (e) {                console.log('prev, do something');            });       新的 events: {            type: "POST",            url: "/home/GetEvents",            data: function () { // a function that returns an object                return {                                     };            }控制器[HttpPost] public JsonResult GetEvents(FiltModel model)                               //model includes string start, end
查看完整描述

1 回答

?
忽然笑

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個(gè)贊

實(shí)現(xiàn)此目的的最佳方法是將事件用作完整日歷文檔中描述的JSON 提要模式。

本質(zhì)上它的工作原理是這樣的:如果您告訴 fullCalendar 控制器操作的 URL,每當(dāng)日歷中的日期范圍發(fā)生變化時(shí)(并且它還沒(méi)有下載該日期范圍的事件),它就會(huì)自動(dòng)向服務(wù)器發(fā)出新請(qǐng)求。它還會(huì)自動(dòng)將“開(kāi)始”和“結(jié)束”日期參數(shù)附加到請(qǐng)求中 - 因此您的服務(wù)器所要做的就是讀取這些參數(shù)并在數(shù)據(jù)庫(kù)查詢(xún)中使用它們來(lái)過(guò)濾返回到日歷的結(jié)果。您還可以選擇將其他相關(guān)數(shù)據(jù)附加到請(qǐng)求中 - 例如其他過(guò)濾器選項(xiàng)。

因此,在您的情況下,您最終會(huì)得到如下代碼:

JavaScript - fullCalendar 事件配置:

events: {

? type: "POST",

? url: "/home/GetEvents",

? data: function () { // a function that returns an object

? return {

? ? //your filter object goes here

? };

}

控制器:


[HttpPost]

public JsonResult GetEvents(FiltModel model) {

? ?//...where the FiltModel class includes start and end parameters - ideally these should be DateTime objects, not strings.


? ?//... then, query the database using the filter options in the model, and return JSON in the format required by fullCalendar

}


查看完整回答
反對(duì) 回復(fù) 2023-09-28
  • 1 回答
  • 0 關(guān)注
  • 193 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)