This is a migrated thread and some comments may be shown as answers.

Recurrence rule exceptions

1 Answer 76 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Oscar Wahlen
Top achievements
Rank 1
Oscar Wahlen asked on 16 May 2011, 04:40 PM
Could anyone provide an example of recurrence rule exception in the latest build (2011.1 419 )? In the documentation it says you must use the AddException method. But I could not find it.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 19 May 2011, 02:38 PM
Hello Oscar,

AddException is a method of the ReccurrenceRule which is set to the appointment. If you provide only one DateTime parameter to the AddException method, the given occurrence will be removed from the recurrence. Note that you should specify the exact Start time of the occurrence. Here is an example of a recurrent appointment with an exception:

var now = DateTime.Now;
var pattern =
new RecurrencePattern() {           
    Frequency = RecurrenceFrequency.Weekly
};
var rule = new RecurrenceRule(pattern);
rule.AddException(now.AddDays(7));
var recurrentApp = new Appointment()
{
    Subject = "recurrent app",
    Start = now,
    End = now.AddHours(1),
    RecurrenceRule = rule
};

If you need to keep the appointment occurrence but change any of its properties (Subject, Start, End..), you should provide two parameters to the AddException method - again DateTime and the exception appointment:

var now = DateTime.Now;
var pattern =
new RecurrencePattern() {           
    Frequency = RecurrenceFrequency.Weekly
};          
var recurrentApp = new Appointment()
{
    Subject = "recurrent app",
    Start = now,
    End = now.AddHours(1)                       
};
var rule = new RecurrenceRule(pattern);          
            
rule.AddException(now, recurrentApp.Copy());
recurrentApp.RecurrenceRule = rule;

Hope this help.

Greetings,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ScheduleView
Asked by
Oscar Wahlen
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or