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

diff event background colors for certain events?

Asked by Anonymous
15 years ago.

Hi,

I wanted to find out if there's a way to flag certain events to appear in one background color and others in another (for a total of 4 or 5 different background colors) based on a field off a datasource. I've downloaded the Pro Trial (and considering to purchse the Pro version if this works) and I couldn't find documentation on how to do this. Sample code to do this would be great if it's possible.

Thanks, John

Comment posted by Dan Letecky
15 years ago.
Yes, this is possible:

1. Specify your data source field by setting DayPilotCalendar.DataTagField. The values in this field get converted to string and are passed as Tag to BeforeEventRender event handler (see below).

2. Handle BeforeEventRender event (double-clicking on the event in Properties window in Visual Studio will create DayPilotCalendar1_BeforeEventRender).

3. Change the background color in the event handler (your special field is accessible as e.Tag):
 protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
  switch (e.Tag)
  {
    case "something":
      e.BackgroundColor = "red";
      break;
    case "somethingelse":
      e.BackgroundColor = "#00ff00";
      break;
  }
}

It's also possible to change color of the column on the left side by setting e.LeftBarColor or modify the event content by setting e.InnerHTML.

I'm still working on the documentation and I hope to get it online soon.

Any other questions are welcome.
Comment posted by Jason
14 years ago.
Will the above code work in the lite version, i'm also looking to change event color backgrounds based on values pulled from the database
Comment posted by Dan Letecky
14 years ago.
Jason, this code works only in the Pro version. I recommend upgrading to Pro version but it can also be done by modifying the source code of the Lite version.
Comment posted by Raymond Booth
11 years ago.

We are setting cell colours based on shift config info, and if something is allocated I want to refelct that in the event somehow.

I tried setting the event duration bar colour but realised I don't have access to the resource id which I need for the shift config lookup. I the#n thought I could store the colur from the before cell render event and use in the before event render but it doesn't appear to follow in order?


Am I missing somehting?

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