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

Format Appointment as Colored Box

4 Answers 56 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
WombatEd
Top achievements
Rank 1
WombatEd asked on 18 Jan 2011, 11:08 PM
I want my appointments to render color coded, and what I've done looks good in FireFox, but not in IE.
I've set up a series of CSS styles like this:

.PlannerItemColorScheme12Color00 { background-color: #72EDDE; }

Now I want to I assign them to appointments, based upon values contained in the underlying data table from which I'm constructing the appointments.

I see this example from the RadScheduler documentation:

protected void RadScheduler1_AppointmentDataBound(object sender, Telerik.Web.UI.SchedulerEventArgs e)
   {
       e.Appointment.CssClass = "MyCustomAppointmentStyle";
   }

The problem is that I need to compute which style to apply, and I don't know how to pull that data out of "sender" or "e".

What's the smart way to do this?

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 19 Jan 2011, 11:37 AM
Hello Ed,

An alternative to setting CssClass property is the BackColor property of the appointment. If you need to store the specific style for an appointments, you can use custom attributes. The Advanced Templates demo shows how you can specify the BackColor and apply it to the appointment via RadColorPicker.


Greetings,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
WombatEd
Top achievements
Rank 1
answered on 19 Jan 2011, 03:36 PM
Thank you for your response, Peter.

The problem I'm having with any is that these tooltips are linked to RadScheduler tooltips, which doesn't handle binding the way most templated controls do.  I mean that, in the RadScheduler.ItemTemplate, I can only bind to Appointment attributes, not to the datasource column that has the color coding info.  So, in the RadScheduler.AppointmentCreatedevent, where I might apply a BackColor, I can't see the color-coding info that I'm retrieving from my database.

Or am I missing something?
0
Peter
Telerik team
answered on 19 Jan 2011, 05:48 PM
Hello Ed,

What I meant was to store the color value in a custom attribute for the appointment. For example, suppose you have a column in your data source called "AppColor". Then you should set CustomAttributeNames="AppColor" for RadScheduler and in AppointmentDataBound, you can access the color value with e.Appointment.Attributes["AppColor"] and use it to set the BackColor for the appointment. This is similar to the Advanced Templates

code behind for the Default page:
protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
      {
          string colorAttribute = e.Appointment.Attributes["AppointmentColor"];
          if (!string.IsNullOrEmpty(colorAttribute))
          {
              int colorValue;
              if (int.TryParse(colorAttribute, out colorValue))
              {
                  int borderColorValue = (int) (colorValue < -0x7F7F7F ? colorValue + 0x202020 : colorValue - 0x202020);
                  e.Appointment.BackColor = Color.FromArgb(colorValue);
                  e.Appointment.BorderColor = Color.FromArgb(borderColorValue);
              }
          }
          e.Appointment.ToolTip = e.Appointment.Subject + ": " + e.Appointment.Description;
      }

I hope this makes it clearer.


Kind regards,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
WombatEd
Top achievements
Rank 1
answered on 22 Jan 2011, 05:09 AM
Problem solved.  (Duhhhh)  I had two different names for my custom attribute, one in the datatable, and one in the markup.
Tags
Scheduler
Asked by
WombatEd
Top achievements
Rank 1
Answers by
Peter
Telerik team
WombatEd
Top achievements
Rank 1
Share this question
or