@using Syncfusion.Blazor.Schedule
<SfSchedule @ref="ScheduleRef" TValue="AppointmentData" Width="100%" Height="550px" @bind-SelectedDate="@CurrentDate"> <ScheduleEvents TValue="AppointmentData" ActionCompleted="OnActionCompleted"></ScheduleEvents> <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings> </SfSchedule> @code{ SfSchedule<AppointmentData> ScheduleRef; DateTime CurrentDate = new DateTime(2020, 3, 10); public void OnActionCompleted(ActionEventArgs<AppointmentData> args) { if (args.ActionType == ActionType.DateNaviagte || args.ActionType == ActionType.ViewNavigate) { List<DateTime> viewDates = ScheduleRef.GetCurrentViewDates(); } } List<AppointmentData> DataSource = new List<AppointmentData> { new AppointmentData { Id = 1, Subject = "Explosion of Betelgeuse Star", Location = "Dallas", StartTime = new DateTime(2020, 1, 8, 9, 30, 0), EndTime = new DateTime(2020, 1, 8, 11, 0, 0) }, new AppointmentData { Id = 2, Subject = "Thule Air Crash Report", Location = "Texas", StartTime = new DateTime(2020, 1, 9, 12, 0, 0), EndTime = new DateTime(2020, 1, 9, 14, 0, 0) }, new AppointmentData { Id = 3, Subject = "Blue Moon Eclipse", Location = "Australia", StartTime = new DateTime(2020, 1, 10, 10, 30, 0), EndTime = new DateTime(2020, 1, 10, 11, 0, 0) }, new AppointmentData { Id = 4, Subject = "Meteor Showers in 2020", Location = "Canada", StartTime = new DateTime(2020, 1, 11, 13, 0, 0), EndTime = new DateTime(2020, 1, 11, 14, 30, 0) }, new AppointmentData { Id = 5, Subject = "Milky Way as Melting pot", Location = "Mexico", StartTime = new DateTime(2020, 1, 12, 12, 0, 0), EndTime = new DateTime(2020, 1, 12, 14, 0, 0) } }; public class AppointmentData { public int Id { get; set; } public string Subject { get; set; } public string Location { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } } } |
I have a similar requirment, this answer is working but we are also planning to use mvvm pattern with blazor wasm. ist there a way to bind CurrentViews Start and End Datetimes to a property in a mvvm friendly way?
Mohammed,
In the MVVM pattern, you can use the CustomAdaptor to get the current view start and end date. For each date and view navigation in this adaptor, the ReadAsync method was called. The DataManagerRequest type parameter in the method had the start and end date of the current view in the param field. You can then bind the values to the property.
UG: https://blazor.syncfusion.com/documentation/scheduler/data-binding#using-custom-adaptor