Skip to content

Commit

Permalink
Implement TodaySelect event in RadzenScheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchev committed May 26, 2024
1 parent d360c58 commit 3e8eb1a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Radzen.Blazor/RadzenScheduler.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ public partial class RadzenScheduler<TItem> : RadzenComponent, IScheduler
[Parameter]
public EventCallback<SchedulerSlotSelectEventArgs> SlotSelect { get; set; }

/// <summary>
/// A callback that will be invoked when the user clicks the Today button.
/// </summary>
/// <example>
/// <code>
/// &lt;RadzenScheduler Data=@appointments TodaySelect=@OnTodaySelect&gt;
/// &lt;/RadzenScheduler&gt;
/// @code {
/// void OnTodaySelect(SchedulerTodaySelectEventArgs args)
/// {
/// args.Today = DateTime.Today.AddDays(1);
/// }
/// }
/// </code>
/// </example>
[Parameter]
public EventCallback<SchedulerTodaySelectEventArgs> TodaySelect { get; set; }

/// <summary>
/// A callback that will be invoked when the user clicks an appointment in the current view. Commonly used to edit existing appointments.
/// </summary>
Expand Down Expand Up @@ -422,7 +440,11 @@ async Task OnPrev()

async Task OnToday()
{
CurrentDate = DateTime.Now.Date;
var args = new SchedulerTodaySelectEventArgs { Today = DateTime.Now.Date };

await TodaySelect.InvokeAsync(args);

CurrentDate = args.Today;

await InvokeLoadData();
}
Expand Down
16 changes: 16 additions & 0 deletions Radzen.Blazor/SchedulerTodaySelectEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Radzen.Blazor;

namespace Radzen
{
/// <summary>
/// Supplies information about a <see cref="RadzenScheduler{TItem}.TodaySelect" /> event that is being raised.
/// </summary>
public class SchedulerTodaySelectEventArgs
{
/// <summary>
/// Today's date. You can change this value to navigate to a different date.
/// </summary>
public DateTime Today { get; set; }
}
}

0 comments on commit 3e8eb1a

Please sign in to comment.