This is a migrated thread and some comments may be shown as answers.
Highlighting recurring appointments in the Calendar
2 Answers 29 Views
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 30 Jul 2010, 10:31 PM
Hi,

I am using two Calendar controls in conjunction with the Scheduler (as seen in the Demo) and I have noticed that recurring appointments do not get highlighted in the Calendar (either one) until one of the "child" appointments is clicked on in the Calendar, and then, only for the Calendar you are in. Also, no recurring appointments appear highlighted if you "page" forward in the Calendars.

So, my question is: Is there a "collection" of recurring appointments generated at some point, or is there a way to generate a collection without the tedium of parsing the RecurrenceRule and generating my own collection each time there is a "refresh" of the appointment data? And, if there is a collection already generated, how does one access it?

Also, is there documentation regarding the "items" in the RecurrenceRule, i.e. tokens and their possible values?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 2
answered on 02 Aug 2010, 07:24 PM
Hi all,

Okay, this is where I am currently-

I found the list of Occurrences that are generated from the RecurrenceRule. I wrote this code in the belief that I could Add Special Days to the radCalendars on my page, as was being done for each Appointment as the data was being bound, hence the use of the RadScheduler1_AppointmentDataBound method. However, during debug (it didn't appear to generated "highlighted" days for the recurring appointments), I discovered that the SpecialDays list in the radCalendar, with the exception of the elements generated outside of the "if statement", are all being set to whatever is the current RadCalendarDay value. As way of illustration, there were 400+ occurrences in the Occurrence List, and all 400+ values in the SpecialDays List contained the last date value from the Occurrences List.

So, my question is-  why do all the elements contain the same value instead of the uniquely different values contained in the Occurrences List?

Code:
protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
 
    RadCalendarDay radCalendarDay = new RadCalendarDay();
    radCalendarDay.Date = e.Appointment.Start;
    radCalendarDay.ItemStyle.CssClass = "DayWithAppointments";
    RadCalendar1.SpecialDays.Add(radCalendarDay);
    RadCalendar2.SpecialDays.Add(radCalendarDay);
 
    if (e.Appointment.RecurrenceRule != "")
    {
 
        RecurrenceRule rrule = RecurrenceRule.TryParse(e.Appointment.RecurrenceRule);
        List<DateTime> occList = rrule.Occurrences.ToList();
        RadCalendarDay rcd = new RadCalendarDay();
 
        foreach (DateTime dt in occList) {
 
            rcd.Date = dt;
            rcd.ItemStyle.CssClass = "DayWithAppointments";
            RadCalendar1.SpecialDays.Add(rcd);
            RadCalendar2.SpecialDays.Add(rcd);
       
        }
    }

The RecurrenceRule that generated the Occurrences List is- 
DTSTART:20100725T060000Z
DTEND:20100725T070000Z
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU
EXDATE:20100912T060000Z,20100808T060000Z

Anyone have any thoughts as to what I am doing wrong here???

Thanks in advance.
0
Chris
Top achievements
Rank 2
answered on 02 Aug 2010, 07:48 PM
Solved the problem. Moved the codeline 

                    RadCalendarDay rcd = new RadCalendarDay();

inside of the foreach, and now everything works fine. All of my recurring appointments are now highlighted in the RadCalendars.






Asked by
Chris
Top achievements
Rank 2
Answers by
Chris
Top achievements
Rank 2
Share this question
or