I am trying to prevent the user from resizing an appointment such that it would overlap with another appointment within the same resource. The problem seems to be when the end of the appointment being resized is dragged over another that is only 1 day in duration, it's not detecting that appointment as being within the start and end dates. I'm using the timeline view where each slot is 1 day.
I can set the start time that it passes to the function to one ms less where it spans the day boundary and it works. If I set it back to 00:00:00 it doesn't.
The code I'm using is below, ResizingTarget() is the handler for the scheduler's OnClientAppointmentResizeEnd event.
function ResizingTarget(sender, args){ if (!isSlotFree(args.get_targetSlot(), args.get_appointment())) { args.get_appointment().get_element().style.border = "0px none black"; args.set_cancel(true); } else { var apt = args.get_appointment(); var newTime = args.get_newStartTime(); var featureId = apt.get_id(); // Call web service to update target }}function isSlotFree(targetSlot, appointment){ //Get start time of target calendar slot var startTime = targetSlot.get_startTime(); //Ensure reference to RadScheduler client object if (_sched == null) _sched = $find( "<%= targets.ClientID %>" ); //Calculate end time (to create span that cannot be overlapped) var endTime = new Date(startTime.getTime() + 86400000); //24hr period startTime = new Date(startTime.getTime()); //Determine if appt being moved overlaps with another appointment return !overlapsWithAnotherAppointment(appointment, startTime, endTime);}function overlapsWithAnotherAppointment(appointment, startTime, endTime){ if (_sched == null) _sched = $find( "<%= targets.ClientID %>" ); // Get all appts in range of start and end time var appointments = _sched.get_appointments().getAppointmentsInRange(startTime, endTime); if (appointments.get_count() == 0) return false; var strID = ""; var apptCnt = appointments.get_count(); for (var i = 0; i < apptCnt; i++) { if (appointments._array[i]._id != appointment._id) { if (appointments._array[i]._serializedResources[0].key == appointment._resources._array[0]._key) return true; } } return false;}