Introducing Recurring Appointments for Web.UI Scheduler ASP.NET AJAX

Posted Fri Nov 6, 2009 @ 12:59 PM

    Web.UI 2009.2 saw the addition of the Scheduler for ASP.NET AJAX control, which handled one-time Appointment objects.  With 2009.3 we have implemented RecurringAppointment objects, allowing one to define appointments that repeat and to fine tune the rules that describe that repetition pattern (SchedulerRecurrencePattern objects).  Scheduler thus now contains two collection of objects, Appointments and RecurringAppointments.  Exceptions, appointments that would otherwise be a member of the RecurringAppointment occurrences, are kept in the Appointments collection.

    On the client Scheduler will examine its list of RecurringAppointments and dynamically generate Appointment instances, adding them temporarily to the Appointments list.  These will be marked by having their instance property set to true and a non-empty RecurringAppointmentID.  If an Appointment is found to have the same Start and RecurringAppointmentID as the potential instance it is considered an exception and the instance creation is skipped.  In this way deleted instances are emulated by setting the exception's visible property to false.

    Client events that are raised on that instance (which will be Appointment events) will need to be handled by the developer, to determine whether the user meant to apply the changes to that instance (in which case it should become an exception Appointment) or to the series as a whole, in which case the changes will apply to the RecurringAppointment.  We do this in our Recurring Appointments and WebService - SOA.UI examples, in the Scheduler1_onAppointmentBeforeRemove() and AppointmentDialog_OnClose() event handlers.

    Ok, let's take a look at how to make one of these new objects on the client.  For this exercise I'll take some of the code from the Client-side API example and describe what's going on in detail.

1.  Create the object and give it an ID.  This ID will be used to track the RecurringAppointment's events so not having one isn't much of an option.

var recurringAppointment2 = new ComponentArt_SchedulerRecurringAppointment();
recurringAppointment2.set_id('R02');

2.  Specify the range (ie. span of time) that the RecurringAppointment will apply to, which for these objects is defined in a Period object.  When creating a ComponentArt_Period you can give it the StartDateTime and Duration in the constructor to save some typing.  Don't forget that the months of JavaScript Date are 0-based indexed!

var range1 = new ComponentArt_Period(new Date(2009,10,2,0,0,0), 1000*60*60*24*5);
recurringAppointment2.set_range(range1);

3.  Describe how the appointment instances should be repeated over the range.  In this example we'll use an OccurrenceType of Weekly, with an Interval of 1 (ie. happening every week) and have the appointment happen on Mondays and Thursdays (1 and 4).

var pattern1 = new ComponentArt_SchedulerRecurrencePattern();
pattern1.set_interval(1);
pattern1.set_occurrenceType(2); // 2:weekly
pattern1.set_daysOfWeek([1, 4]);
recurringAppointment2.set_pattern(pattern1);

4.  Define the Appointment that will be used as a template, whose properties will be copied by Scheduler into the appointment instances.

var appointment2 = new ComponentArt_SchedulerAppointment();
appointment2.set_appointmentID('R02_0');
appointment2.set_start(new Date(2009, 10, 2, 16, 0, 0));
appointment2.set_duration(1000 * 60 * 45); // 45 minutes
appointment2.set_title('Swimming');
appointment2.set_description('');
recurringAppointment2.set_appointment(appointment2);

  Hopefully this gives you a better understanding of our approach to repeated appointments.  Thanks for reading!

Posted to Hwan Hong by hwan

Posted on Fri Nov 6, 2009 @ 12:59 PM

Filed under:

Comments

There are currently no comments for this blog post.

Anonymous comments are not allowed. Click here to log in or create an account.