我正在使用Jquery完整日历事件,一切正常。在这里,每当我们单击Jquery对话框时,每个事件都会加载Jquery对话框。现在对于某些特定事件,它应该避免该事件可单击仅显示我尝试了以下事情。
脚本为:
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventClick: updateEvent,
selectable: true,
selectHelper: true,
select: selectDate,
editable: false,
events: "JsonResponse.ashx",
eventDrop: eventDropped,
eventResize: eventResized,
eventRender: function(event, element) {
//alert(event.title);
element.qtip({
content: event.activity,
position: { corner: { tooltip: 'bottomLeft', target: 'topRight'} },
style: {
border: {
width: 1,
radius: 3,
color: '#2779AA'
},
padding: 10,
textAlign: 'center',
tip: true, // Give it a speech bubble tip with automatic corner detection
name: 'cream' // Style it according to the preset 'cream' style
}
});
}
});
});
这是 .ashx 文件方法,其中加载每个事件。
private String convertCalendarEventIntoString(CalendarEvent cevent)
{
String allDay = "true";
string editable =""
if(cevent.Holiday == "Y")
{
editable = "false";
}
else
{
editable = "true"
}
if (ConvertToTimestamp(cevent.start).ToString().Equals(ConvertToTimestamp(cevent.end).ToString()))
{
if (cevent.start.Hour == 0 && cevent.start.Minute == 0 && cevent.start.Second == 0)
{
allDay = "true";
}
else
{
allDay = "false";
}
}
else
{
if (cevent.start.Hour == 0 && cevent.start.Minute == 0 && cevent.start.Second == 0
&& cevent.end.Hour == 0 && cevent.end.Minute == 0 && cevent.end.Second == 0)
{
allDay = "true";
}
else
{
allDay = "false";
}
}
return "{" +
"id: '" + cevent.id + "'," +
"title: '" + cevent.projectname.Replace("'", "|") + "/" + cevent.activity.Replace("'", "|") + "'," +
"start: " + ConvertToTimestamp(cevent.start).ToString() + "," +
"end: " + ConvertToTimestamp(cevent.end).ToString() + "," +
"allDay:" + allDay + "," +
"projectnumber: '" + cevent.projectnumber + "'" + "," +
"projectname: '" + cevent.projectname.Replace("'", "|") + "'" + "," +
"projectdescription: '" + cevent.projectdescription.Replace("'", "") + "'" + "," +
"activity: '" + cevent.activity.Replace("'", "|") + "'" + "," +
"Regular: '" + cevent.Regular + "'" + "," +
"OverTime: '" + cevent.OverTime + "'" + "," +
"RegularDisplay: '" + cevent.RegularDisplay + "'" + "," +
"OvertimeDisplay: '" + cevent.OvertimeDisplay + "'" + "," +
"Remark1: '" + cevent.Remark1 + "'" + "," +
"Remark2: '" + cevent.Remark2 + "'" + "," +
"Remark3: '" + cevent.Remark3 + "'" + "," +
"className: '" + cevent.colorclassname + "'" + "," +
"Duration: '" + cevent.Duration + "'" + "," +
"Customername: '" + cevent.Customername + "'" + "," +
"Status:'" + cevent.Status + "'" + "," +
"editable: " + editable +
//"backgroundColor:" + backgroundColor + "," +
"},";
}
上面的代码当事件在假期时,它应该防止可怜的.....对于该特定事件...此代码不起作用
尝试替换这个..
events: "JsonResponse.ashx",
跟:
eventSources: [
{
url: 'JsonResponse.ashx',
type: 'GET',
data: {},
error: function () {
//error do nothing.
}
success: function (response) {
return response;
}
}
],
其他方法.. 根据您的需要处理错误情况。
var events = {
url: 'JsonResponse.ashx',
type: 'GET',
data: { },
success: function (response) {
return response;
}
};
$('#calendar').fullCalendar({
events: events
});
并在转换日历事件到字符串(日历事件事件)方法返回错误/错误..,以便该事件不会被注册。需要成功处理响应。
我不是 ashx 方面的专家,但我认为你需要做这样的事情......如果错误
context.Response.setStatus(400);
还
context.Response.Write(jsondatastring);
只需在全日历中像这样编辑您的eventClick函数
eventClick: function(calEvent, jsEvent, view) {
if(calEvent.editable=="true") // here you campare condition to call your "updateEvent" function
{
updateEvent();
}
else
{
//show alert like not appicable
}
}