From 3e8eb1a6ebdf5dcae9ca61a595be9d384446debe Mon Sep 17 00:00:00 2001 From: Atanas Korchev Date: Sun, 26 May 2024 10:53:55 +0300 Subject: [PATCH] Implement TodaySelect event in RadzenScheduler --- Radzen.Blazor/RadzenScheduler.razor.cs | 24 ++++++++++++++++++- .../SchedulerTodaySelectEventArgs.cs | 16 +++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Radzen.Blazor/SchedulerTodaySelectEventArgs.cs diff --git a/Radzen.Blazor/RadzenScheduler.razor.cs b/Radzen.Blazor/RadzenScheduler.razor.cs index a87163b65c1..694c4201c73 100644 --- a/Radzen.Blazor/RadzenScheduler.razor.cs +++ b/Radzen.Blazor/RadzenScheduler.razor.cs @@ -152,6 +152,24 @@ public partial class RadzenScheduler : RadzenComponent, IScheduler [Parameter] public EventCallback SlotSelect { get; set; } + /// + /// A callback that will be invoked when the user clicks the Today button. + /// + /// + /// + /// <RadzenScheduler Data=@appointments TodaySelect=@OnTodaySelect> + /// </RadzenScheduler> + /// @code { + /// void OnTodaySelect(SchedulerTodaySelectEventArgs args) + /// { + /// args.Today = DateTime.Today.AddDays(1); + /// } + /// } + /// + /// + [Parameter] + public EventCallback TodaySelect { get; set; } + /// /// A callback that will be invoked when the user clicks an appointment in the current view. Commonly used to edit existing appointments. /// @@ -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(); } diff --git a/Radzen.Blazor/SchedulerTodaySelectEventArgs.cs b/Radzen.Blazor/SchedulerTodaySelectEventArgs.cs new file mode 100644 index 00000000000..1ffde4cbc02 --- /dev/null +++ b/Radzen.Blazor/SchedulerTodaySelectEventArgs.cs @@ -0,0 +1,16 @@ +using System; +using Radzen.Blazor; + +namespace Radzen +{ + /// + /// Supplies information about a event that is being raised. + /// + public class SchedulerTodaySelectEventArgs + { + /// + /// Today's date. You can change this value to navigate to a different date. + /// + public DateTime Today { get; set; } + } +} \ No newline at end of file