22 Answers, 1 is accepted
You can build a recurrence rules using the RecurrencePattern and RecurrenceRange objects. Then, you create the rule using:
To create the rule, and assign it to the RecurrenceRules string property of the Appointment object.
You can also refer to this topic:
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
If the Freq_type is 16, Freq_interval is 6 and the Freq_recurrence_factor is 2 then the description created up by sql is...
"Occurs every 2 month(s) on day 6 of that month at 12:00:00 AM. Schedule will be used starting on 11/10/2008."
If the Freq_type is 32, Freq_interval is 5 and the Freq_recurrence_factor is 6 then the description created up by sql is...
"Occurs every third Thursday of every 6 month(s) at 12:00:00 AM. Schedule will be used starting on 12/5/2008.
So my question now is how yould you use the MonthlyRecurrenceRule to specify the day of the week and that week of the month like "third thursday of every 6 months"?
I did see that you can do
I figure its the 2nd one i should be using but im not quite sure what a dayordinal is other then every day of the year such as 1-365.
I setup this test for myself to determine what were the pattern/range values for an object. For each of those scenarios is:
Subject: Month by day recur
Start: 3/3/2009 8:30:00 AM/End: 3/3/2009 9:30:00 AM
Recurs: DTSTART:20090303T083000Z DTEND:20090303T093000Z RRULE:FREQ=MONTHLY;COUNT=20;INTERVAL=2;BYMONTHDAY=5
Pattern: Day of Month: 5, Day Ordinal: 0, Day of Week Mask: None, First Day of Week: Sunday, Frequency: Monthly, Interval: 2, Month: None
Range: Start: 3/3/2009 8:30:00 AM, Duration: 01:00:00, Max Occurrences: 20, Recurs Until: 12/31/9999 11:59:59 PM
Subject: Third Tuesday Recur
Start: 3/4/2009 9:00:00 AM/End: 3/4/2009 10:00:00 AM
Recurs: DTSTART:20090304T090000Z DTEND:20090304T100000Z RRULE:FREQ=MONTHLY;UNTIL=20110401T000000Z;INTERVAL=1;BYSETPOS=3;BYDAY=TU
Pattern: Day of Month: 0, Day Ordinal: 3, Day of Week Mask: Tuesday, First Day of Week: Sunday, Frequency: Monthly, Interval: 1, Month: None
Range: Start: 3/4/2009 9:00:00 AM, Duration: 01:00:00, Max Occurrences: 2147483647, Recurs Until: 4/1/2011 12:00:00 AM
Of course, you have to tailor them a little bit, but HTH.
For the Third Tuesday rule, for example, you'd use:
new MonthlyRecurrenceRule(3, DaysOfWeekMask.Tuesday, 1, range);
//where 3 is the 3rd week of, and the 1 is the every one month interval parameters
For the other:
new MonthlyRecurrenceRule(5, 2, range);
//where 5 is day 5, and 2 is every 2 month interval parameters
DaysOfWeekMask is represented by the RecurrenceDay enumeration, which does have Weekdays or WeekendDays as options as well. The only thing I didn't see was option 8 - Day. What does that mean?
Is there another variance I didn't see? I'm not quite sure as to all the rules the 32 option has...
It may be the case where multiple appointments handle this situation...
However i do think i may have the code right...im just not sure how to actually trigger the recurrence to show up as appointments on the control.
Here's what i have...
It's hard to see in your code the various paths. I can say for the third day in 6 months, it would be:
new MonthlyRecurrenceRule(3, 6, range);
Are you binding appointments using a DataSourceControl, using the DataSource property and calling DataBind, using the in-built provider, or simply by adding appointments to the appointments collection? If you are using InsertAppointment to generate the appointments, I think you have to do that on every page load...
When you switch views, it needs bound again, so that may be the issue.
OK, a few things, in response to your data below:
|RadCal.DataKeyField = 0|
|RadCal.DataStartField = "10/15/1988"|
|RadCal.DataEndField = "10/15/1988"|
|RadCal.DataSubjectField = "Date"|
These fields should be the name of the fields you bind to; so you can bind a data source against the scheduler, and these would be the field names to bind to, not the field data itself.
For testing purposes, try calling your AddAppointments method on every page load, or are you?
I just saw something: try changing your code to something like this instead:
//create recurrence rule and specify range as you do
Dim DailyRR as new DailyRecurrenceRule(...);
da.RecurrenceRules = DailyRR.ToString();
And that's it; instead of looping through using the occurrences collection, try just set the RecurrenceRules property to the string of the recurrence rule.
It might take some debugging to figure that out; in my experience with the scheduler, something wasn't getting bound at the right time. One of the issues was I was binding data for the current date (available through the VisibleStartDate and VisibileEndDate properties) in the NavigationCommand event, instead of the NavigateComplete event. Could that be another part of the issue?