Prevent all day appointment being created

2 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 11 Sep 2013 Link to this post

    How do I go about prevent all day appointments being created. If I create an appointment in the scheduler as normal and drag it to the top of the scheduler into the all day bar it changes the times to an all day event. I want to prevent them double clicking in the all day event bar or dragging and dropping an appointment in to this bar.

    I've tried the following but it still allows me to create appointments
    void rsTest_CellFormatting(object sender, SchedulerCellEventArgs e)
              if (e.CellElement is SchedulerHeaderCellElement)
                  e.CellElement.Enabled = false;
                  e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
  2. George
    George avatar
    500 posts

    Posted 16 Sep 2013 Link to this post

    Hello Karl,

    Thank you for writing.

    You can prevent all day appointments from being created by subscribing to the CollectionChanged event of the Appointments collection of the RadScheduler:
    this.scheduler.Appointments.CollectionChanging += Appointments_CollectionChanging;

    The event handler looks like this:
    void Appointments_CollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
        if (e.Action == NotifyCollectionChangedAction.Add && e.NewItems.Count > 0)
            Appointment newApp = e.NewItems[0] as Appointment;
            if (this.IsAllDayAppointment(newApp))
                e.Cancel = true;

    The method for checking if the given appointment is all day event is this:
    private bool IsAllDayAppointment(Appointment app)
        if ((app.Start.Minute == 0 && app.Start.Hour == 0 && app.Start.Second == 0) &&
            (app.End.Minute == 59 && app.End.Hour == 23 && app.End.Second == 59))
            return true;
        return false;

    I hope this helps. For any further questions, do not hesitate to ask.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top