Current View Dates

Hello

I am using the Scheduler control to show data i read from my webservice. 
I need to read from the service any time the user switches view or moves to a different month etc..
I am currently using OnActionCompleted and check RequestType for dateNavigate and viewNavigate. However i am unable to find any way to know what the first and last date of the view currently shown is?

I have tried this: 
var viewDates = await Schedule.GetCurrentViewDates();

Schedule is a reference to the control.

Any advice would be greatly appreciated.

Thanks

Atle

3 Replies 1 reply marked as answer

SK Satheesh Kumar Balasubramanian Syncfusion Team October 22, 2020 11:16 AM UTC

  
Hi Atle, 
  
We have validated your reported problem at our end and let you know that we can get the first and last date of the current view using GetCurrentView public method. 

Code snippet:  
@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; } 
    } 
} 
  
  
Kindly try the above solution and let us know if this is helpful. 
  
Note: Please use the latest nuget version(18.3.42) 
  
Regards, 
Satheesh Kumar B 


Marked as answer

KA Karro replied to Satheesh Kumar Balasubramanian January 17, 2023 10:07 AM UTC

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?



SR Swathi Ravi Syncfusion Team January 19, 2023 04:07 PM UTC

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




Attachment: blazor_wasm_custom_adaptor_4308629f.zip

Loader.
Up arrow icon