Delete Occurrence / Recurrence Exceptions in code?

4 posts, 0 answers
  1. Simon
    Simon avatar
    47 posts
    Member since:
    May 2008

    Posted 26 Nov 2012 Link to this post

    Hi All,

    Can someone tell me what is the correct way to handle deletes programmatically for occurrences and recurrence exceptions?

    Deleting a simple, non-recurring booking with a call to RadScheduleView.Remove(apptA) causes the RadScheduleView.AppointmentDeleted event to fire.. From this event, we can remove apptA from our data store--finalising the "delete" operation. The same path is taken when deleting a recurring series. Removing the series "Master" from the RadScheduleView and then the data store removes all occurrences.

    But what about deleting only one occurrence out of several or deleting an exception to the recurrence rule? This does not cause AppointmentDeleted to fire, so how do we finalise the "delete" operation? What happens behind the scenese? What entities are affected?

    Also, according to this page, "you can delete an appointment using the code. Just Call Remove() method of the RadScheduleView control. It returns whether or not the appointment or the occurrence can be removed." Why might an appointment NOT be removable? Also note that we are managing our AppointmentSource, loading and unloading appointments as users move forward and back in time. We are not able to use the CollectionChanged handler of this collection to watch for deletions or additions.

    Thanks for your help--
    Scott


  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Nov 2012 Link to this post

    Hi Scott,

    When an occurrence of a recurrent appointment is deleted, AppointmentEditing and AppointmentEdited events of the ScheduleView are fired. In AppointmentEditing event handler the second argument which is of type AppointmentEditingEventArgs has IsDeleted property - it is true when the occurrence is deleted, false when the occurrence is edited. More information about RadScheduleView events can be found here.

    As to the second question - the method returns false in cases when the parameter is not of type IAppointment or Occurrence, also when you try to delete an appointment which is at the same time in edit mode.

    Hope this helps. If you have any additional issues/questions, please let us know.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Simon
    Simon avatar
    47 posts
    Member since:
    May 2008

    Posted 02 Dec 2012 Link to this post

    Hi Yana,

    Thanks--It is becoming clearer now. One more question: when deleting a recurrence exception (Occurrence.State = RecurrenceState.Exception), what code should I add to "persist" the deletion in our dataset?

    I see that I can use ScheduleViewAppointmentEditing event handler to identify the deletion by testing for 
    ((appointmentEditingEventArgs.Occurrence.State == RecurrenceState.Exception) && appointmentEditingEventArgs.IsDeleted)

    Then what? Should I remove the appointEditingEventArgs.Occurrence from the appointmentEditingEventArgs.Appointment.RecurrenceRule.Exceptions collection? Or should I somehow use appointmentEditingEventArgs.Appointment.RecurrenceRule.RemoveException() method?

    If I do nothing, the recurrence exception appears again as soon as I reload my Appointment data from the database.

    Cheers,
    Scott
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 05 Dec 2012 Link to this post

    Hello Scott,

    I am not sure how your database is designed.  If you're following our example ( check the database diagram here), you will have SqlExceptionOccurrences table where all the exception dates from the RecurrenceRule are saved and SqlExceptionAppointments table where the properties for the exceptions are preserved.  These tables should be updated when deleting/editing occurrences.

    Hope this helps.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top