New to Telerik UI for ASP.NET MVCStart a free 30-day trial

Change the Background Color of an Event Dynamically in the Scheduler

Environment

Product Version2024.1.130
ProductTelerik UI for ASP.NET MVC Scheduler

Description

How can I change the color of the entire element of the Telerik UI for ASP.NET MVC Scheduler component's events dynamically?

Solution

  1. Create a property within the Scheduler Model that will hold the Color field.
  2. Subscribe to the DataBound event of the Scheduler.
  3. Within the event handler, iterate over the event records and their DOM element counterparts and explicitly change their background color by using the jQuery css() method.
Index.cshtml
    @(Html.Kendo().Scheduler<SchedulerModel>()
        .Name("scheduler")
        .StartTime(new DateTime(2013, 6, 13, 7, 00, 00))
        .Height(600)
        .Editable(false)
        .Events(events => events.DataBound("onDataBound"))
        .Views(views =>
        {
            views.DayView();
            views.WorkWeekView(workWeekView =>
            {
                workWeekView.Selected(true);
            });
            views.WeekView();
            views.MonthView();
        })
        .Timezone("Etc/UTC")
        .BindTo(@data)
    )

To see a full implementation of the aforementioned approach refer to the following REPL example on dynamically changing the background color of specified events in the Scheduler.

More ASP.NET MVC Scheduler Resources

See Also