Hello,
What’s the best way to mark special days in RadzenScheduler like Holidays (New Year’s Day, Epiphany, Easter, Corpus Christi…)?
Robert
Hello,
What’s the best way to mark special days in RadzenScheduler like Holidays (New Year’s Day, Epiphany, Easter, Corpus Christi…)?
Robert
Hi @Mad.Rain,
You can use the SlotRender event to apply styling based on a condition. Here is an example from our online demo:
void OnSlotRender(SchedulerSlotRenderEventArgs args)
{
// Highlight today in month view
if (args.View.Text == "Month" && args.Start.Date == DateTime.Today)
{
args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));";
}
// Highlight working hours (9-18)
if ((args.View.Text == "Week" || args.View.Text == "Day") && args.Start.Hour > 8 && args.Start.Hour < 19)
{
args.Attributes["style"] = "background: var(--rz-scheduler-highlight-background-color, rgba(255,220,40,.2));";
}
}
Hello, I'd like it to look like the Outlook calendar (see image) - I have a table called "Holiday" (see image) where I've stored the entries, and I need to display these in addition to the events... What would be the best way to do this?
Hi @Mad.Rain,
I am not sure what you want to display based on your screenshot - you have circled the whole slot. Clarification is needed.
You can use the AppointmentRender event to customize the Appointment display:
void OnAppointmentRender(SchedulerAppointmentRenderEventArgs<Appointment> args)
{
// Never call StateHasChanged in AppointmentRender - would lead to infinite loop
if (args.Data.Text == "Birthday")
{
args.Attributes["style"] = "background: red";
}
}
Our online demo (linked before) uses it to make the Birthday appointment red. You can use args to determine if the appointment is special (and requires custom styling) or not.
Is there a convenient, one-time event where I can load the holidays? I currently have to load the holiday list from the database for the current year to then populate the OnAppointmentRender.
You can usually use the OnInitializedAsync method of your page. It is fired only once.
Yes, I know that – but I don't want to load all holidays for all years at once. I want to load those of the current year first, and then dynamically load them when the user changes the year in RadzenScheduler. Is there an event that indicates when the days/weeks/months/years change?
You can try the LoadData event of RadzenScheduler.