New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Change the Background Color of an Event Dynamically in the Scheduler
Environment
Product Version | 2024.1.130 |
Product | Telerik UI for ASP.NET Core Scheduler |
Description
How can I change the color of the entire element of the Telerik UI for ASP.NET Core Scheduler component's events dynamically?
Solution
- Create a property within the Scheduler Model that will hold the
Color
field. - Subscribe to the
DataBound
event of the Scheduler. - 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.
Razor
@(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 Telerik REPL examples: