我正在使用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 + "," +
"},";
}
上面的代码,当事件在假期时应该阻止cickable .....对于那个特定的事件......这段代码不能正常工作
答案 0 :(得分:1)
尝试替换它..
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
});
并在convertCalendarEventIntoString(CalendarEvent cevent)方法中返回false / error ..这样事件就不会注册。 需要成功处理响应。
我不是ashx的专家,但我认为你需要做那样的事情...... 如果错误
context.Response.setStatus(400);
其他
context.Response.Write(jsondatastring);
答案 1 :(得分:0)
只需编辑您的活动在fullcalendar中单击此功能
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
}
}