Delete the appointments in the entire row
Environment
Product | Telerik WebForms Scheduler for ASP.NET AJAX |
Description
Sometimes, one might want to delete all the appointments in a given row.
Solution
To delete the whole row of appointments at once, you can follow these steps:
- Attach the
AppointmentDelete
event. - Retrieve the start and end hours of the appointment currently being deleted.
- Compare the start and end hours with the other appointments.
- Remove the appointments that have the same start and end hours.
The below example's code is based on the Binding to Generic List demo:
protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
{
int startHour = e.Appointment.Start.Hour;
int endHour = e.Appointment.End.Hour;
List<AppointmentInfo> appointmentsToDelete = Appointments.Where(ap => ap.Start.Hour == startHour && ap.End.Hour == endHour).ToList();
foreach (AppointmentInfo appointment in appointmentsToDelete)
{
Appointments.Remove(appointment);
}
}
Please note that this code will only work for appointments that have the same start and end hour, meaning they are placed on the same row.