Target cell based on event type?

Asked by Tom
10 years ago.

Is there a way to target the cell which an event is in? I need to add a custom background colour for the cell based on what type of event is on that day.

This is in regard to using the calendar in month view.

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

You can use onBeforeCellRender event like this:

//...
dp.onBeforeCellRender = function(args) {
  var events = dp.events.forRange(args.cell.start, args.cell.end);

  // check events array for event types....
  // ...
  
  // has events?
  var hasEvents = !events.isEmpty();
  if (hasEvents) {
    args.cell.cssClass = "has-events";
  }
};

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