search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Different event colors in DayPilot Month

Asked by KonstiPisti
12 years ago.

Hi, I'm using DayPilot Month, and I'd like to adjust different colors for different kind of events.
I can turn off css styling, and use custom rendering, but then it looks bad.
Is there a way to use css styling, and still adjust different colors to events?

Answer posted by Kevin
12 years ago.

This is not hard at all. Here is a code snippet which I use for my offices which turn different events into different colors (based on the first two letters).

Event: "FG - Out of Office"

protected void DayPilotMonth1_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Month.BeforeEventRenderEventArgs e)
{
if (e.Text.ToString().IndexOf("OB Call") > 0)
e.BackgroundColor = "#99FFFF";
else
{
string physician = e.Text.ToString().Substring(0, 2); //<-- This grabs the "FG"

//RB physicians
switch (physician)
{
case "CB":
e.BackgroundColor = "#66CC44";
break;
case "KB":
e.BackgroundColor = "#FFAA00";
break;
case "FG":
e.BackgroundColor = "#FFFF33";
break;
case "PJ":
e.BackgroundColor = "#FF4466";
break;
case "BK":
e.BackgroundColor = "#00CC33";
break;
case "ST":
e.BackgroundColor = "#CC44CC";
break;
case "CY":
e.BackgroundColor = "#99FF00";
break;
default:
e.BackgroundColor = "#96FF7D";
break;
}

}
}

Hope that helps!!

Answer posted by KonstiPisti
12 years ago.

Thanks for your quick reply!
I'm doing something similar, but it works only when CssClassPrefix is not set for the DayPilotMonth control
(just as in the demo "custom rendering" on daypilot site).
However when I set it, all events will appear grey - no matter what background color I used.

Comment posted by KonstiPisti
12 years ago.

By the way I'm using this version
7.1.2695.0

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.