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

Custom Event Styling in React Scheduler

Asked by Anonymous
1 year ago.

In the React Scheduler, I am trying to apply custom styles to specific events based on certain conditions.

The goal is to color-code the events according to their status. For example, 'completed' events should be green, 'in-progress' should be blue, and 'pending' should be yellow.

How can I do that?

Answer posted by Dan Letecky [DayPilot]
1 year ago.

You can use the onBeforeEventRender event handler to customize the events.

A sample implementation could look like this:

onBeforeEventRender: (args) => {
  if(args.data.status === "completed") {
      args.data.backColor = "#008000"; // Green for completed events
  } else if(args.data.status === "in-progress") {
      args.data.backColor = "#0000FF"; // Blue for in-progress events
  } else if(args.data.status === "pending") {
      args.data.backColor = "#FFFF00"; // Yellow for pending events
  }
}

The status field is a custom property that stores the event status. Here it is stored at the top level but if you use multiple custom value it is better to store it under the tag property to avoid name collision with the built-in properties.

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