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

Colour coding appointments using Exchange categories

2 Answers 95 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
jwhitley
Top achievements
Rank 1
jwhitley asked on 27 Apr 2010, 11:20 AM
I've seen a number of posts which cover the colour coding of appointments, but none which would appear to apply to using the ExchangeScheduleProvider as the data source.

I need to emulate the same basic colours that a user using Oulook would see. Exchange stores this data under the "Categories" attribute of the calendar item, and by default uses values such as "Red Category".

Having looked through a Telerik Appointment object at runtime which references an appointment in Exchange which has a category set, this data does not seem to appear anywhere in the Appointment object. Specifically, the Resources collection is empty.

Can this be achieved, and has my searching failed to find an existing forum topic?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 30 Apr 2010, 01:13 PM
Hello John,

Please, refer to the Exchange Provider help topic. The exchange provider class that we provide can be easily extended to accomodate resources. I have attached a modified version of the ExchangeSchedulerProvider.cs class that shows how to add resources. You can set the BackColor property of the appointment in the CreateAppointmentsFromCalendarItem method:


protected
virtual IEnumerable<Appointment> CreateAppointmentsFromCalendarItem(RadScheduler owner, string sharedCalendarName, CalendarItemType calendarItem)
        {
            Appointment calendarAppointment = new Appointment();
            calendarAppointment.ID = calendarItem.ItemId.Id;
            calendarAppointment.Subject = calendarItem.Subject;
            calendarAppointment.Start = calendarItem.Start;
            calendarAppointment.End = calendarItem.End;
            calendarAppointment.Owner = owner;            
  
            calendarAppointment.Attributes[ExchangeIdAttribute] = calendarItem.ItemId.Id;
            calendarAppointment.Attributes[ExchangeChangeKeyAttribute] = calendarItem.ItemId.ChangeKey;
              
            //Get any additional data to display.
            calendarAppointment.Attributes["Location"] = calendarItem.Location;
            calendarAppointment.Attributes["Organizer"] = calendarItem.Organizer.Item.Name;
  
            //Create a ToolTip similar to the one in Outlook.
            const string hourFormat = "%h:mmtt";
            string tooltip = String.Format("{0}-{1} {2}\n({3})",
                calendarItem.Start.ToString(hourFormat).ToLower(),
                calendarItem.End.ToString(hourFormat).ToLower(),
                calendarItem.Subject,
                calendarItem.Location);
  
            calendarAppointment.ToolTip = tooltip;
  
            if (sharedCalendarName != null)
            {
                calendarAppointment.Resources.Add(owner.Resources.GetResource("SharedCalendar", sharedCalendarName));
            }
  
            //Set calendarAppointment.BackColor conditionally based on the resource 



Kind regards,
Peter
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.
0
jwhitley
Top achievements
Rank 1
answered on 30 Apr 2010, 02:02 PM
Lovely, thank you.
Tags
Scheduler
Asked by
jwhitley
Top achievements
Rank 1
Answers by
Peter
Telerik team
jwhitley
Top achievements
Rank 1
Share this question
or