Class RadzenScheduler<TItem>
Displays a collection of AppointmentData in day, week or month view.
public class RadzenScheduler<TItem> : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IScheduler
Type Parameters
TItem
The type of the value item.
- Inheritance
-
RadzenScheduler<TItem>
- Implements
- Inherited Members
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"
},
};
}
Constructors
RadzenScheduler()
public RadzenScheduler()
Properties
AppointmentMouseEnter
A callback that will be invoked when the user moves the mouse over an appointment in the current view.
[Parameter]
public EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> AppointmentMouseEnter { get; set; }
Property Value
AppointmentMouseLeave
A callback that will be invoked when the user moves the mouse out of an appointment in the current view.
[Parameter]
public EventCallback<SchedulerAppointmentMouseEventArgs<TItem>> AppointmentMouseLeave { get; set; }
Property Value
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.
[Parameter]
public EventCallback<SchedulerAppointmentMoveEventArgs> AppointmentMove { get; set; }
Property Value
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.
[Parameter]
public Action<SchedulerAppointmentRenderEventArgs<TItem>> AppointmentRender { get; set; }
Property Value
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.
[Parameter]
public EventCallback<SchedulerAppointmentSelectEventArgs<TItem>> AppointmentSelect { get; set; }
Property Value
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.
[Parameter]
public RenderFragment ChildContent { get; set; }
Property Value
- RenderFragment
The child content.
CurrentDate
Gets or sets the current date displayed by the selected view. Initially set to Date. Changes during navigation.
public DateTime CurrentDate { get; set; }
Property Value
- 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.
[Parameter]
public IEnumerable<TItem> Data { get; set; }
Property Value
- IEnumerable<TItem>
The data.
Date
Gets or sets the initial date displayed by the selected view. Set to DateTime.Today
by default.
[Parameter]
public DateTime Date { get; set; }
Property Value
- DateTime
The date.
EndProperty
Specifies the property of TItem
which will set End.
[Parameter]
public string EndProperty { get; set; }
Property Value
- string
The name of the property. Must be a
DateTime
property.
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.
[Parameter]
public EventCallback<SchedulerLoadDataEventArgs> LoadData { get; set; }
Property Value
MonthSelect
A callback that will be invoked when the user clicks a month header button.
[Parameter]
public EventCallback<SchedulerMonthSelectEventArgs> MonthSelect { get; set; }
Property Value
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).
[Parameter]
public EventCallback<SchedulerMoreSelectEventArgs> MoreSelect { get; set; }
Property Value
Examples
<RadzenScheduler Data=@appointments MoreSelect=@OnMoreSelect>
</RadzenScheduler>
@code {
void OnMoreSelect(SchedulerMoreSelectEventArgs args)
{
args.PreventDefault();
}
}
NextText
Gets or sets the text of the next button. Set to Next
by default.
[Parameter]
public string NextText { get; set; }
Property Value
- string
The next text.
PrevText
Gets or sets the text of the previous button. Set to Previous
by default.
[Parameter]
public string PrevText { get; set; }
Property Value
- string
The previous text.
SelectedIndex
Specifies the initially selected view.
[Parameter]
public int SelectedIndex { get; set; }
Property Value
- int
The index of the selected.
SelectedView
Gets the SelectedView.
public ISchedulerView SelectedView { get; }
Property Value
SlotRender
An action that will be invoked when the current view renders an slot. Never call StateHasChanged
when handling SlotRender.
[Parameter]
public Action<SchedulerSlotRenderEventArgs> SlotRender { get; set; }
Property Value
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.
[Parameter]
public EventCallback<SchedulerSlotSelectEventArgs> SlotSelect { get; set; }
Property Value
Examples
<RadzenScheduler Data=@appointments SlotSelect=@OnSlotSelect>
</RadzenScheduler>
@code {
void OnSlotSelect(SchedulerSlotSelectEventArgs args)
{
}
}
StartProperty
Specifies the property of TItem
which will set Start.
[Parameter]
public string StartProperty { get; set; }
Property Value
- string
The name of the property. Must be a
DateTime
property.
Template
Gets or sets the template used to render appointments.
[Parameter]
public RenderFragment<TItem> Template { get; set; }
Property Value
- 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.
[Parameter]
public string TextProperty { get; set; }
Property Value
- string
The name of the property. Must be a
DateTime
property.
TodaySelect
A callback that will be invoked when the user clicks the Today button.
[Parameter]
public EventCallback<SchedulerTodaySelectEventArgs> TodaySelect { get; set; }
Property Value
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.
[Parameter]
public string TodayText { get; set; }
Property Value
- string
The today text.
Methods
AddView(ISchedulerView)
public Task AddView(ISchedulerView view)
Parameters
view
ISchedulerView
Returns
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
Dispose()
public override void Dispose()
GetAppointmentAttributes(AppointmentData)
public IDictionary<string, object> GetAppointmentAttributes(AppointmentData item)
Parameters
item
AppointmentData
Returns
GetAppointmentsInRange(DateTime, DateTime)
public IEnumerable<AppointmentData> GetAppointmentsInRange(DateTime start, DateTime end)
Parameters
Returns
GetComponentCssClass()
protected override string GetComponentCssClass()
Returns
GetSlotAttributes(DateTime, DateTime)
public IDictionary<string, object> GetSlotAttributes(DateTime start, DateTime end)
Parameters
Returns
IsAppointmentInRange(AppointmentData, DateTime, DateTime)
public bool IsAppointmentInRange(AppointmentData item, DateTime start, DateTime end)
Parameters
item
AppointmentDatastart
DateTimeend
DateTime
Returns
IsSelected(ISchedulerView)
public bool IsSelected(ISchedulerView view)
Parameters
view
ISchedulerView
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnInitialized()
protected override void OnInitialized()
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.
public Task Reload()
Returns
RemoveView(ISchedulerView)
public void RemoveView(ISchedulerView view)
Parameters
view
ISchedulerView
RenderAppointment(AppointmentData)
public RenderFragment RenderAppointment(AppointmentData item)
Parameters
item
AppointmentData
Returns
Resize(double, double)
Invoked from client-side via interop when the scheduler size changes.
[JSInvokable]
public void Resize(double width, double height)
Parameters
SelectAppointment(AppointmentData)
public Task SelectAppointment(AppointmentData data)
Parameters
data
AppointmentData
Returns
SelectMonth(DateTime, IEnumerable<AppointmentData>)
public Task SelectMonth(DateTime monthStart, IEnumerable<AppointmentData> appointments)
Parameters
monthStart
DateTimeappointments
IEnumerable<AppointmentData>
Returns
SelectMore(DateTime, DateTime, IEnumerable<AppointmentData>)
public Task<bool> SelectMore(DateTime start, DateTime end, IEnumerable<AppointmentData> appointments)
Parameters
start
DateTimeend
DateTimeappointments
IEnumerable<AppointmentData>
Returns
SelectSlot(DateTime, DateTime)
public Task SelectSlot(DateTime start, DateTime end)
Parameters
Returns
SelectSlot(DateTime, DateTime, IEnumerable<AppointmentData>)
public Task<bool> SelectSlot(DateTime start, DateTime end, IEnumerable<AppointmentData> appointments)
Parameters
start
DateTimeend
DateTimeappointments
IEnumerable<AppointmentData>
Returns
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.
public Task SelectView(ISchedulerView view)
Parameters
view
ISchedulerViewThe ISchedulerView to select
Returns
SetParametersAsync(ParameterView)
public override Task SetParametersAsync(ParameterView parameters)
Parameters
parameters
ParameterView