이 질문은 반복되는 질문 일 수 있지만 다른 방법은 없습니다. 전체 일정에서 이전 및 다음 버튼을 클릭 할 때 값을 표시해야합니다. 아약스 및 값을 올바르게 사용하는 콘솔에서 볼 수 있습니다. 지금은 내가 만 난 그 달의 데이터에 액세스 할 수있는 현재 월의 첫 날을 전달하려는 아약스 결과에서 전체 캘린더 표시가 공백이 될 수도 있습니다.
- 데이터가 표시되지 않을 수 있습니다. 이벤트에 기본 시작 및 종료 값이 있음을 압니다. 그러나 특정 월의 첫 데이트가 필요합니다
WebMethod는 해당 버튼을 클릭 할 때마다 항상 나타납니다. 이것은 내 콘솔의 결과입니다. 결과 만 2017년 8월 1일 및 2017년 8월 31일 사이에 데이터를 표시 여기
[WebMethod]
public static IList GetEvents(string Start, string End)
{
String Date = "10/01/2016";
IList events = new List<Event>();
//Hard coded the date for testing yyyy-MM-dd
DateTime startDate = Convert.ToDateTime("2017-08-01");//Convert.ToDateTime(Date);
DateTime endDate = Convert.ToDateTime("2017-08-31");//StartDate.AddMonths(1);
SqlConnection con1 = new SqlConnection(Connection.str);
BLL_Attentance Att = new BLL_Attentance();
DataSet ds = new DataSet();
double OS_Idno = 2587470;
string AccYear = "2017-2018";
try
{
DataTable dt = Att.AttentanceLoadFull(Convert.ToDouble(1236), 3, startDate.ToString(), endDate.ToString(), AccYear);//OP_sp_Attendance_Load
ds.Tables.Add(dt);
}
catch (Exception ex)
{
ex.Message.ToString();
}
for (DateTime i = startDate; i < endDate; i = i.AddDays(1))
{
if (ds.Tables[0].Rows.Count > 0)
{
// to check ds contains the current date
DataRow[] Date1 = ds.Tables[0].Select("OSA_Dateofattendance = '" + i + "'");
if (Date1.Count() == 0)
{
}
else
{
string flag = "Present";
/*New Code*/
DataTable ds3 = new DataTable();
string sub = "2017-2018".Substring(0, 4);
string OS_Attendance = "OS_Attendance" + sub;
SqlDataAdapter sda3 = new SqlDataAdapter("select Oid from " + OS_Attendance.ToString() + " where Oattn_date='" + i.ToString("MM-dd-yyyy") + "' and M_idno='" + 3 + "' and Oattn_acadyear='2017-2018' and Os_idno='" + OS_Idno + "'", con1);
sda3.Fill(ds3);
/*New Code End*/
if (ds3.Rows.Count > 0)
{
flag = "Absent";
}
if (flag == "Absent")
{
events.Add(new Event
{
EventName = "Absent",
StartDate = i.ToString("dd-MM-yyyy"),
});
}
else
{
events.Add(new Event
{
EventName = "Presnt",
StartDate = i.ToString("dd-MM-yyyy"),
});
}
}
}
}
return events;
}
public class Event
{
public Guid EventID { get { return new Guid(); } }
public string EventName { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public int ImageType { get; set; }
public string Url { get; set; }
}
뒤에
Array(6)
0
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "01-08-2017", EndDate: null, ImageType: 0, …}
1
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "02-08-2017", EndDate: null, ImageType: 0, …}
2
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "03-08-2017", EndDate: null, ImageType: 0, …}
3
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "04-08-2017", EndDate: null, ImageType: 0, …}
4
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "07-08-2017", EndDate: null, ImageType: 0, …}
5
:
{EventID: "00000000-0000-0000-0000-000000000000", EventName: "Presnt", StartDate: "08-08-2017", EndDate: null, ImageType: 0, …}
length
:
6
JQUERY
$(document).ready(function() {
$('div[id*=calendar1]').show();
$('div[id*=calendar1]').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: function (start, end,timezone, callback) {
$.ajax({
type: "POST",
contentType: "application/json",
data: "{Start:'" + start + "',End:'" + end + "'}",
url: "attendance-full.aspx/GetEvents",
dataType: "json",
// Old Code
//success: function (data) {
// console.log(data);
// for (var i = 0; i < data.d.length; i++) {
// var event = new Object();
// event.id = data.d[i].EventName;
// event.start = new Date(data.d[i].StartDate);
// event.title = data.d[i].EventName;
// return event;
// }
//}
//New Code
success: function (doc) {
console.log(doc);
var my_events = [];
if (!doc.result) {
$.each(doc.d, function (index, elem) {
my_events.push({
id:elem.EventName,
title: elem.EventName,
start: elem.StartDate,
});
});
callback(my_events);
}
}
});
}
});
$('#loading').hide();
$('div[id*=fullcal]').show();
});
코드. 2017 년 8 월에 데이터가 표시되지 않았습니다. 나
내가 새로운 다음 코드 캘린더 표시 2017년 7월 8일에서 단일 날짜 다른 날짜 Click the link to view my result를 표시하지 않습니다으로 지정됩니다 내 아약스 코드를 변경
을 편집 도와주세요. 당신의 AJAX 기능이 제공되는 콜백을 통해 fullCalendar에 데이터를 전송하지 않습니다, 당신은 함수에서 반환하고의 끝에서
moment.min.js:6 Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
Error
at $ (http://localhost:4047/assets/global/plugins/moment.min.js:6:6788)
at http://localhost:4047/assets/global/plugins/moment.min.js:6:25765
at http://localhost:4047/assets/global/plugins/moment.min.js:6:145
at http://localhost:4047/assets/global/plugins/moment.min.js:6:149
'events : "attendance-full.aspx/GetEvents"'시도 했습니까? Ajax는 이미 Fullcalendar에 내장되어 있습니다. 이 [문서 페이지] (https : // fullcalendar.io/docs/event_data/events_json_feed /). –
@LouysPatriceBessette하지만 사용하지 마십시오. 내가 아약스를 제거하면 코드에 가까운 영향을 미친다. – Jks
@LouysPatriceBessette은 서버의 JSON 출력이 fullCalendar에서 지원하는 형식 일 때만 작동합니다. 이 경우에는 그렇지 않습니다. – ADyson