Unable to get selected date

Hi,

I have a Scheduler control on my page. I'm using only the Day view and I'm using ScheduleResources. 
During the initialization of the component I'm loading events for today and the resources as well:
protected override async Task OnInitializedAsync()
{
            selectedDate = DateTime.Now.Date;
            Appointments = (await calendarService.GetAppointments(selectedDate)).ToList();   
            Resources = (await calendarService.GetResources()).ToList();        
}

And when the user change the date in the scheduler, I would like to load events for the selected date:
protected async void OnActionCompleted(ActionEventArgs args)
{
        switch (args.RequestType)
        {
            case "dateNavigate":
            case "viewNavigate":
                var dates = await ScheduleRef.GetCurrentViewDates();
                var selectedDate = (DateTime)dates[0];
                Appointments = (await calendarService.GetAppointments(selectedDate)).ToList();
                break;
        }
}

However this doesn't work! 
ScheduleRef.GetCurrentViewDates() is returning an empty list!

Can someone tell me how to handle such simple case?

Thanks

Mohamed 


1 Reply 1 reply marked as answer

NR Nevitha Ravi Syncfusion Team July 13, 2020 02:21 PM UTC

Hi Mohammed, 

Greetings from Syncfusion Support. 

We have validated the reported scenario at our end and suggest you to use custom adaptor. The ReadAsync method will trigger for each actions of scheduler which have the current view’s start and end date as Params in dataManagerRequest. We have prepared a sample for your reference which can be downloaded from the following link. 

  public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) 
    { // in dataManagerRequest.Params you will get the start and end date of the current view. 
        await Task.Delay(100); //To mimic asynchronous operation, we delayed this operation using Task.Delay 
… 

Please try the solution and let us know if you need any further assistance. 

Regards, 
Nevitha. 


Marked as answer
Loader.
Up arrow icon