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

dynamically set background

Asked by Anonymous
6 years ago.

i need to set background to lets say gray for all past events and to something else for future events. Is it possible?

Comment posted by Dan Letecky [DayPilot]
6 years ago.

Yes, you can use BeforeEventRender event to customize the event appearance:

protected void DayPilotScheduler1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
  if (e.Start < DateTime.Now) {
    e.BackgroundColor = "#cccccc";
  }
}

See also:
https://doc.daypilot.org/scheduler/event-customization/

Comment posted by Anonymous
6 years ago.

Dan,
thank you for your reply. I probably mixed up terminology. What i meant is not actually event itself but rather entire background of calendar.

Answer posted by Dan Letecky [DayPilot]
6 years ago.

You can also change the background color of the grid cells, the mechanism is the same. Just use BeforeCellRender event handler:

protected void DayPilotScheduler1_BeforeCellRender(object sender, DayPilot.Web.Ui.Events.BeforeCellRenderEventArgs e)
{
  if (e.Start < DateTime.Now) {
    e.BackgroundColor = "#cccccc";
  }
}

See also:
https://doc.daypilot.org/scheduler/cell-customization/

Comment posted by Vinay K
6 years ago.

Hi Dan,
I have a problem with the background color of the event. I have set it in the same way as above in the Before Event Render but when i do an Event Move i need to change the background color again. I am able to update the Scheduler event but the color doesn't change because the Before Event Render event doesn't fire again. How can i fire the event again when i execute Event Move?

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