Implement TodaySelect event in RadzenScheduler

This commit is contained in:
Atanas Korchev
2024-05-26 10:53:55 +03:00
parent d360c584c1
commit 3e8eb1a6eb
2 changed files with 39 additions and 1 deletions

View File

@@ -152,6 +152,24 @@ namespace Radzen.Blazor
[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>
@@ -422,7 +440,11 @@ namespace Radzen.Blazor
async Task OnToday()
{
CurrentDate = DateTime.Now.Date;
var args = new SchedulerTodaySelectEventArgs { Today = DateTime.Now.Date };
await TodaySelect.InvokeAsync(args);
CurrentDate = args.Today;
await InvokeLoadData();
}

View File

@@ -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; }
}
}