Class RadzenScheduler<TItem>
Displays a collection of AppointmentData in day, week or month view.
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenScheduler<TItem> : RadzenComponent, IDisposable, IScheduler
Type Parameters
Name | Description |
---|---|
TItem | The type of the value item. |
Examples
<RadzenScheduler Data="@data" TItem="DataItem" StartProperty="Start" EndProperty="End" TextProperty="Text">
<RadzenMonthView />
</RadzenScheduler>
@code {
class DataItem
{
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string Text { get; set; }
}
DataItem[] data = new DataItem[]
{
new DataItem
{
Start = DateTime.Today,
End = DateTime.Today.AddDays(1),
Text = "Birthday"
},
};
}
Properties
AppointmentMouseEnter
A callback that will be invoked when the user moves the mouse over an appointment in the current view.
Declaration
public EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> AppointmentMouseEnter { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> |
AppointmentMouseLeave
A callback that will be invoked when the user moves the mouse out of an appointment in the current view.
Declaration
public EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> AppointmentMouseLeave { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> |
AppointmentMove
A callback that will be invoked when an appointment is being dragged and then dropped on a different slot. Commonly used to change it to a different timeslot.
Declaration
public EventCallback<SchedulerAppointmentMoveEventArgs> AppointmentMove { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerAppointmentMoveEventArgs> |
Examples
<RadzenScheduler Data=@appointments AppointmentMove=@OnAppointmentMove>
</RadzenScheduler>
@code {
async Task OnAppointmentMove(SchedulerAppointmentMoveEventArgs moved)
{
var draggedAppointment = appointments.SingleOrDefault(x => x == (Appointment)moved.Appointment.Data);
if (draggedAppointment != null)
{
draggedAppointment.Start = draggedAppointment.Start + moved.TimeSpan;
draggedAppointment.End = draggedAppointment.End + moved.TimeSpan;
await scheduler.Reload();
}
}
}
AppointmentRender
An action that will be invoked when the current view renders an appointment. Never call StateHasChanged
when handling AppointmentRender.
Declaration
public Action<SchedulerAppointmentRenderEventArgs<TItem>> AppointmentRender { get; set; }
Property Value
Type | Description |
---|---|
Action<SchedulerAppointmentRenderEventArgs<TItem>> |
Examples
<RadzenScheduler Data=@appointments AppointmentRender=@OnAppointmentRendert>
</RadzenScheduler>
@code {
void OnAppintmentRender(SchedulerAppointmentRenderEventArgs<TItem> args)
{
if (args.Data.Text == "Birthday")
{
args.Attributes["style"] = "color: red;"
}
. }
}
AppointmentSelect
A callback that will be invoked when the user clicks an appointment in the current view. Commonly used to edit existing appointments.
Declaration
public EventCallback<SchedulerAppointmentSelectEventArgs<TItem>> AppointmentSelect { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerAppointmentSelectEventArgs<TItem>> |
Examples
<RadzenScheduler Data=@appointments AppointmentSelect=@OnAppointmentSelect>
</RadzenScheduler>
@code {
void OnAppointmentSelect(SchedulerAppointmentSelectEventArgs<TItem> args)
{
}
}
ChildContent
Gets or sets the child content of the scheduler. Use to specify what views to render.
Declaration
public RenderFragment ChildContent { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment | The child content. |
CurrentDate
Gets or sets the current date displayed by the selected view. Initially set to Date. Changes during navigation.
Declaration
public DateTime CurrentDate { get; set; }
Property Value
Type | Description |
---|---|
DateTime | The current date. |
Data
Gets or sets the data of RadzenScheduler. It will display an appointment for every item of the collection which is within the current view date range.
Declaration
public IEnumerable<TItem> Data { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<TItem> | The data. |
Date
Gets or sets the initial date displayed by the selected view. Set to DateTime.Today
by default.
Declaration
public DateTime Date { get; set; }
Property Value
Type | Description |
---|---|
DateTime | The date. |
EndProperty
Specifies the property of TItem
which will set End.
Declaration
public string EndProperty { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the property. Must be a |
LoadData
A callback that will be invoked when the scheduler needs data for the current view. Commonly used to filter the data assigned to Data.
Declaration
public EventCallback<SchedulerLoadDataEventArgs> LoadData { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerLoadDataEventArgs> |
MonthSelect
A callback that will be invoked when the user clicks a month header button.
Declaration
public EventCallback<SchedulerMonthSelectEventArgs> MonthSelect { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerMonthSelectEventArgs> |
Examples
<RadzenScheduler Data=@appointments MonthSelect=@OnMonthSelect>
</RadzenScheduler>
@code {
void OnMonthSelect(SchedulerTodaySelectEventArgs args)
{
args.Month = DateTime.Month.AddMonth(1);
}
}
MoreSelect
A callback that will be invoked when the user clicks the more text in the current view. Commonly used to view additional appointments. Invoke the PreventDefault() method to prevent the default action (showing the additional appointments).
Declaration
public EventCallback<SchedulerMoreSelectEventArgs> MoreSelect { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerMoreSelectEventArgs> |
Examples
<RadzenScheduler Data=@appointments MoreSelect=@OnMoreSelect>
</RadzenScheduler>
@code {
void OnMoreSelect(SchedulerMoreSelectEventArgs args)
{
args.PreventDefault();
}
}
NavigationTemplate
Gets or sets the additional content to be rendered in place of the default navigation buttons in the scheduler. This property allows for complete customization of the navigation controls, replacing the native date navigation buttons (such as year, month, and day) with user-defined content or buttons. Use this to add custom controls or interactive elements that better suit your application's requirements.
Declaration
public RenderFragment NavigationTemplate { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment | The custom navigation template to replace default navigation buttons. |
NextText
Gets or sets the text of the next button. Set to Next
by default.
Declaration
public string NextText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The next text. |
PrevText
Gets or sets the text of the previous button. Set to Previous
by default.
Declaration
public string PrevText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The previous text. |
SelectedIndex
Specifies the initially selected view.
Declaration
public int SelectedIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The index of the selected. |
SelectedView
Gets the SelectedView.
Declaration
public ISchedulerView SelectedView { get; }
Property Value
Type | Description |
---|---|
ISchedulerView |
SlotRender
An action that will be invoked when the current view renders an slot. Never call StateHasChanged
when handling SlotRender.
Declaration
public Action<SchedulerSlotRenderEventArgs> SlotRender { get; set; }
Property Value
Type | Description |
---|---|
Action<SchedulerSlotRenderEventArgs> |
Examples
<RadzenScheduler Data=@appointments SlotRender=@OnSlotRender>
</RadzenScheduler>
@code {
void OnSlotRender(SchedulerSlotRenderEventArgs args)
{
if (args.View.Text == "Month" && args.Start.Date == DateTime.Today)
{
args.Attributes["style"] = "background: red;";
}
}
}
SlotSelect
A callback that will be invoked when the user clicks a slot in the current view. Commonly used to add new appointments.
Declaration
public EventCallback<SchedulerSlotSelectEventArgs> SlotSelect { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerSlotSelectEventArgs> |
Examples
<RadzenScheduler Data=@appointments SlotSelect=@OnSlotSelect>
</RadzenScheduler>
@code {
void OnSlotSelect(SchedulerSlotSelectEventArgs args)
{
}
}
StartProperty
Specifies the property of TItem
which will set Start.
Declaration
public string StartProperty { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the property. Must be a |
Template
Gets or sets the template used to render appointments.
Declaration
public RenderFragment<TItem> Template { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<TItem> | The template. |
Examples
<RadzenScheduler Data="@data" TItem="DataItem" StartProperty="Start" EndProperty="End" TextProperty="Text">
<Template Context="data">
<strong>@data.Text</strong>
</Template>
<ChildContent>
<RadzenMonthView />
</ChildContent>
</RadzenScheduler>
TextProperty
Specifies the property of TItem
which will set Text.
Declaration
public string TextProperty { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the property. Must be a |
TodaySelect
A callback that will be invoked when the user clicks the Today button.
Declaration
public EventCallback<SchedulerTodaySelectEventArgs> TodaySelect { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<SchedulerTodaySelectEventArgs> |
Examples
<RadzenScheduler Data=@appointments TodaySelect=@OnTodaySelect>
</RadzenScheduler>
@code {
void OnTodaySelect(SchedulerTodaySelectEventArgs args)
{
args.Today = DateTime.Today.AddDays(1);
}
}
TodayText
Gets or sets the text of the today button. Set to Today
by default.
Declaration
public string TodayText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The today text. |
Methods
AddView(ISchedulerView)
Adds a view. Must be called when a ISchedulerView is initialized.
Declaration
public async Task AddView(ISchedulerView view)
Parameters
Type | Name | Description |
---|---|---|
ISchedulerView | view | The view to add. |
Returns
Type | Description |
---|---|
Task |
Dispose()
Detaches event handlers and disposes Reference.
Declaration
public override void Dispose()
Overrides
GetAppointmentAttributes(AppointmentData)
Gets the appointment HTML attributes.
Declaration
public IDictionary<string, object> GetAppointmentAttributes(AppointmentData item)
Parameters
Type | Name | Description |
---|---|---|
AppointmentData | item | The appointment. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> | A dictionary containing the HTML attributes for the specified appointment. |
GetAppointmentsInRange(DateTime, DateTime)
Gets the appointments in the specified range.
Declaration
public IEnumerable<AppointmentData> GetAppointmentsInRange(DateTime start, DateTime end)
Parameters
Type | Name | Description |
---|---|---|
DateTime | start | The start of the range. |
DateTime | end | The end of the range. |
Returns
Type | Description |
---|---|
IEnumerable<AppointmentData> | A collection of appointments within the specified range. |
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected override string GetComponentCssClass()
Returns
Type | Description |
---|---|
System.String |
Overrides
GetSlotAttributes(DateTime, DateTime)
Gets the slot HTML attributes.
Declaration
public IDictionary<string, object> GetSlotAttributes(DateTime start, DateTime end)
Parameters
Type | Name | Description |
---|---|---|
DateTime | start | The start of the slot. |
DateTime | end | The end of the slot. |
Returns
Type | Description |
---|---|
IDictionary<System.String, System.Object> | A dictionary containing the HTML attributes for the specified slot. |
IsAppointmentInRange(AppointmentData, DateTime, DateTime)
Determines whether an appointment is within the specified range.
Declaration
public bool IsAppointmentInRange(AppointmentData item, DateTime start, DateTime end)
Parameters
Type | Name | Description |
---|---|---|
AppointmentData | item | The appointment to check. |
DateTime | start | The start of the range. |
DateTime | end | The end of the range. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsSelected(ISchedulerView)
Determines whether the specified view is selected.
Declaration
public bool IsSelected(ISchedulerView view)
Parameters
Type | Name | Description |
---|---|---|
ISchedulerView | view | The view. |
Returns
Type | Description |
---|---|
System.Boolean |
|
OnAfterRenderAsync(Boolean)
Called by the Blazor runtime.
Declaration
protected override async Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type | Description |
---|---|
Task |
Overrides
OnInitialized()
Called by the Blazor runtime.
Declaration
protected override void OnInitialized()
Overrides
Reload()
Causes the current scheduler view to render. Enumerates the items of Data and creates instances of AppointmentData to display in the current view. Use it when Data has changed.
Declaration
public async Task Reload()
Returns
Type | Description |
---|---|
Task |
RemoveView(ISchedulerView)
Removes a view. Must be called when a ISchedulerView is disposed.
Declaration
public void RemoveView(ISchedulerView view)
Parameters
Type | Name | Description |
---|---|---|
ISchedulerView | view | The view to remove. |
RenderAppointment(AppointmentData)
Renders the appointment.
Declaration
public RenderFragment RenderAppointment(AppointmentData item)
Parameters
Type | Name | Description |
---|---|---|
AppointmentData | item | The item. |
Returns
Type | Description |
---|---|
RenderFragment | RenderFragment. |
Resize(Double, Double)
Invoked from client-side via interop when the scheduler size changes.
Declaration
public void Resize(double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | width | The width. |
System.Double | height | The height. |
SelectAppointment(AppointmentData)
Selects the specified appointment.
Declaration
public async Task SelectAppointment(AppointmentData data)
Parameters
Type | Name | Description |
---|---|---|
AppointmentData | data | The appointment to select. |
Returns
Type | Description |
---|---|
Task |
SelectMonth(DateTime, IEnumerable<AppointmentData>)
Selects the specified month.
Declaration
public async Task SelectMonth(DateTime monthStart, IEnumerable<AppointmentData> appointments)
Parameters
Type | Name | Description |
---|---|---|
DateTime | monthStart | The start of the month. |
IEnumerable<AppointmentData> | appointments | The appointments for this range. |
Returns
Type | Description |
---|---|
Task |
SelectMore(DateTime, DateTime, IEnumerable<AppointmentData>)
Selects the specified more link.
Declaration
public async Task<bool> SelectMore(DateTime start, DateTime end, IEnumerable<AppointmentData> appointments)
Parameters
Type | Name | Description |
---|---|---|
DateTime | start | The start. |
DateTime | end | The end. |
IEnumerable<AppointmentData> | appointments | The appointments for this range. |
Returns
Type | Description |
---|---|
Task<System.Boolean> |
SelectSlot(DateTime, DateTime)
Selects the specified slot.
Declaration
public async Task SelectSlot(DateTime start, DateTime end)
Parameters
Type | Name | Description |
---|---|---|
DateTime | start | The start. |
DateTime | end | The end. |
Returns
Type | Description |
---|---|
Task |
SelectSlot(DateTime, DateTime, IEnumerable<AppointmentData>)
Selects the specified slot.
Declaration
public async Task<bool> SelectSlot(DateTime start, DateTime end, IEnumerable<AppointmentData> appointments)
Parameters
Type | Name | Description |
---|---|---|
DateTime | start | The start. |
DateTime | end | The end. |
IEnumerable<AppointmentData> | appointments | The appointments for this range. |
Returns
Type | Description |
---|---|
Task<System.Boolean> |
SelectView(ISchedulerView)
Selects the specified ISchedulerView. The view must already be present in this scheduler. If the specified view is already selected, no action will be performed.
Declaration
public async Task SelectView(ISchedulerView view)
Parameters
Type | Name | Description |
---|---|---|
ISchedulerView | view | The ISchedulerView to select |
Returns
Type | Description |
---|---|
Task |
SetParametersAsync(ParameterView)
Called by the Blazor runtime when parameters are set.
Declaration
public override async Task SetParametersAsync(ParameterView parameters)
Parameters
Type | Name | Description |
---|---|---|
ParameterView | parameters | The parameters. |
Returns
Type | Description |
---|---|
Task |
Overrides
Explicit Interface Implementations
IScheduler.HasAppointmentMoveDelegate()
Declaration
bool IScheduler.HasAppointmentMoveDelegate()
Returns
Type | Description |
---|---|
System.Boolean |
IScheduler.HasMouseEnterAppointmentDelegate()
Declaration
bool IScheduler.HasMouseEnterAppointmentDelegate()
Returns
Type | Description |
---|---|
System.Boolean |
IScheduler.Height
Declaration
double IScheduler.Height { get; }
Returns
Type | Description |
---|---|
System.Double |
IScheduler.MouseEnterAppointment(ElementReference, AppointmentData)
Declaration
async Task IScheduler.MouseEnterAppointment(ElementReference reference, AppointmentData data)
Parameters
Type | Name | Description |
---|---|---|
ElementReference | reference | |
AppointmentData | data |
Returns
Type | Description |
---|---|
Task |
IScheduler.MouseLeaveAppointment(ElementReference, AppointmentData)
Declaration
async Task IScheduler.MouseLeaveAppointment(ElementReference reference, AppointmentData data)
Parameters
Type | Name | Description |
---|---|---|
ElementReference | reference | |
AppointmentData | data |
Returns
Type | Description |
---|---|
Task |