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

dynamically set background

Asked by Anonymous
5 months 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]
5 months 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
5 months 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]
5 months 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
4 months 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?

New Reply
This reply is
Your name (optional):