--------------
--------------
recurrence: "Recurrence",
recurrenceRule: "RecurrenceRule"
},
appointmentClick: "readOnlyChange", //Bind the events to trace the appointment and make it as read only based on requirement
appointmentHover: "readOnlyChange",
appointmentWindowOpen: "readOnlyChange",
appointmentDeleted: "readOnlyChange",
resizeStop: "readOnlyChange",
dragStop: "readOnlyChange",
create: "onCreate" //Bind the event to apply the appointment creation by selecting cells
function onCreate(args) {
this._on(this.element, "mouseup", "td.e-workcells,td.e-monthcells,td.e-alldaycells", function (oEl) {
if ($(oEl.target).hasClass("e-workcells") || $(oEl.target).hasClass("e-monthcells") || $(oEl.target).hasClass("e-alldaycells")) {
var schObj = $("#Schedule").data("ejSchedule");
var tds = schObj.element.find('td.e-selectedCell');
var nt = tds.length - 1;
if (nt == 0) {
schObj._cellSelection(oEl.target);
}
else {
schObj._multipleCellAppointCreation(oEl.target);
}
if (!$(oEl.target).hasClass("e-workcells") ? (new Date(schObj.cur_EndTime) - new Date(schObj.cur_StartTime)) / 3600000 > 24 : (new Date(schObj.cur_EndTime) - new Date(schObj.cur_StartTime)) / 3600000 > 0.5) { //If you want to create appointment by click on cell remove this highlighted if block
var createObject = { Subject:"Person 2",StartTime: new Date(schObj.cur_StartTime), EndTime: new Date(schObj.cur_EndTime) };
schObj.saveAppointment(createObject); //Create object and save in schedule control
}
}
});
}
function readOnlyChange(args) {
if (args.originalEventType != "cellDoubleClick") {
var data = ej.DataManager(this._processed).executeLocal(new ej.Query().where("Id", "equal", args.appointment.Id))
for (var i = 0; i < data.length; i++) {
if (data[i].Subject == "Person 1") //Check the subject which has Person 1 to make it read-only
args.cancel = true;
}
}
}
</code>
Kindly try the above sample and let us know if you need further assistance on this.
Regards,
Sarath Kumar P K
$(function () {
$("#Schedule1").ejSchedule({
width: "100%",
height: "525px",
--------------
--------------
appointmentSaved: "appValidate",
appointmentEdited: "appValidate",
appointmentClick: "readOnlyChange",
appointmentHover: "readOnlyChange",
appointmentWindowOpen: "readOnlyChange",
appointmentDeleted: "readOnlyChange",
resizeStop: "readOnlyChange",
dragStop: "readOnlyChange", //Check for readOnly and validate the condition too.
create: "onCreate"
});
});
function appValidate(args) {
var schObj = $("#Schedule1").data("ejSchedule");
var appList = schObj._processed;
for (var i = 0; i < appList.length; i++) {
if ((args.type == "appointmentSaved" ? true : (appList[i][schObj.model.appointmentSettings["id"]]!=args.appointment.Id))&&(new Date(appList[i][schObj.model.appointmentSettings["endTime"]]) > new Date(args.appointment.StartTime))) { //Check the required condition for appointment create
if ((new Date(appList[i][schObj.model.appointmentSettings["startTime"]]) < new Date(args.appointment.EndTime))) {
if (new Date(new Date(appList[i][schObj.model.appointmentSettings["startTime"]]).setHours(0, 0, 0, 0)).getTime() === new Date(new Date(args.appointment.StartTime).setHours(0, 0, 0, 0)).getTime()) { }
args.cancel = true; //Return false if condition satisfies (Overlap)
}
}
}
}
</code>
Kindly try the above sample and let us know if you need further assistance on this.
Regards,
Sarath Kumar P K