Skip to main content

How to: Filter Appointments

The following example demonstrates how to filter appointments displayed within a scheduler according to a condition. The ASPxSchedulerDataWebControlBase.FilterAppointment event is intended specifically for this purpose. The code below demonstrates how to hide all tentative appointments (those whose status is set to AppointmentStatusType.Tentative).

using DevExpress.XtraScheduler;
using DevExpress.Web.ASPxScheduler;
// ...

protected void ASPxScheduler1_FilterAppointment(object sender, PersistentObjectCancelEventArgs e) {
    // Filter all tentative appointments.
    int statusID =  ASPxScheduler1.Storage.Appointments.Statuses.GetStandardStatusId(
        AppointmentStatusType.Tentative);

    e.Cancel = ((Appointment)e.Object).StatusId == statusID;
}