Sequence contains no elements exception in UpdateSchedule method

Hi,

We have problem with updating appointments. We obtain exception - Sequence contains no elements in

System.Linq.Enumerable.First<Java.Util.Calendar>(System.Collections.ObjectModel.ObservableCollection<Java.Util.Calendar> source) in 
Com.Syncfusion.Schedule.AppointmentEngine.GetVisibleAppointments(System.Collections.ObjectModel.ObservableCollection<Java.Util.Calendar> visibleDateRange, Com.Syncfusion.Schedule.ScheduleAppointmentCollection appointments) in 
Com.Syncfusion.Schedule.SfSchedule.UpdateVisibleAppointments(System.Collections.ObjectModel.ObservableCollection<Java.Util.Calendar> visibleDates) in 
Com.Syncfusion.Schedule.SfSchedule.UpdateAppointments(System.Collections.ObjectModel.ObservableCollection<Java.Util.Calendar> visibleDates) in 
Com.Syncfusion.Schedule.SfSchedule.UpdateSchedule() 

In constructor of calendar fragment we have:

this.WhenActivated(disposable =>
{
     this.ViewModel
            .Events
       .Changed.Select(_ => Unit.Default)
       .StartWith(Unit.Default)
            .ObserveOn(RxApp.MainThreadScheduler)
       .Subscribe(_ =>
                  
    {
                       _schedule.ItemsSource = new ScheduleAppointmentCollection();
                       _schedule.ItemsSource = CreateAppointments();

                        Task.Run(() =>
                           {
                             Activity.RunOnUiThread(() =>
                              {
                                _schedule.UpdateSchedule();   <- this is problematic method                                     
                               });
                                });
    
                              }).DisposeWith(disposable);
                       (...) 

This method works after a while, with some delay. ItemsSource is not empty while we call update schedule.
Thanks for any help.

8 Replies

VR Vigneshkumar Ramasamy Syncfusion Team August 14, 2018 11:33 AM UTC

Hi Anna Koprowicz-Boukoffa 
 
Thanks for contacting Syncfusion support. 
 
We have checked with the provided information. We can reproduce the issue “Sequence contains no elements exception” when UpdateSchedule method is used. We suspect that your requirement to use UpdateSchedule method is to update the appointments at run time. In schedule, appointments will be updated at runtime (while updating ItemSource) without using UpdateSchedule method. So, UpdateSchedule method is not recommended, which will recreate the view unnecessarily. Could you please confirm on your requirement to use UpdateSchedule method?  
  
Regards,  
Vigneshkumar R 



MB Maciej Brazewicz August 14, 2018 02:15 PM UTC

When updating ItemSource in schedule - appointment indicator dots that are shown in month view are not redrawn for new appointments. That is why we used UpdateSchedule method because it forced them to be redrawn. But then we get the mentioned above exception.

So there are actually two issues here. 



VR Vigneshkumar Ramasamy Syncfusion Team August 15, 2018 07:44 AM UTC

Hi Anna Koprowicz-Boukoffa  
 
We are not able to reproduce the issue “appointment indicator in month view is not redrawn when when appointments are updated”, it is working properly. By default, maximum three dots of appointment indicator will be displayed, even if the month cell contains more than 3 appointments. You can customize the number of appointment indicators displayed in month cell using AppointmentIndicatorCount property of MonthViewSettings. Kindly refer our online User Guide Documentation by using the below link.  
  
  
Please let us know if you need further assistance on this.  
  
Regards,  
Vigneshkumar R 



MB Maciej Brazewicz August 16, 2018 09:22 AM UTC

Hi, sorry for the confusion but now we know where the real problem is. Apparently in our code we handle MonthCellLoaded event and pass our own view to EventArgs.View to display dots (so we can add "+X" if there are more appointments rather than show more dots). But in case of adding appointments after initial load this event is not firing for  cells with new appointments. So they are loaded with no appointments in EventArgs.Appointments and will not update afterwards. Is it intended behavior? 


VR Vigneshkumar Ramasamy Syncfusion Team August 18, 2018 08:13 AM UTC

Hi Anna Koprowicz-Boukoffa, 
 
We have checked with the provided information. When appointment is added at run time, month cell loaded event will not be fired only the appointments will be updated in the view, that is the actual behavior of schedule control.  
 
Regarding the issue “Sequence contains no elements exception” when UpdateSchedule method is called, we have already found and fixed the issue. We will include this issue fix in our upcoming Volume 3 release which is expected to be available by month of September. We appreciate your patience until then. 
 
Regards, 
Vigneshkumar R  



MB Maciej Brazewicz August 22, 2018 07:38 AM UTC

If MonthCellLoaded is not firing what is the right way to update custom view in MonthCell after updating appointments at run time? As I mentioned we are showing there our custom view with "dots". Is there any suggested way of doing it or should we just wait for fixed UpdateSchedule method because it is the way to do it?


AA Arulraj A Syncfusion Team August 23, 2018 11:30 AM UTC

Hi Maciej, 
 
Thanks for the update. 
 
As of now, UpdateSchedule method is the only way to update the appointment indicator in month cell when appointments are added at run time in Xamarin.Android. As we mentioned in our previous update, we will include the fix for the reported issue in our Volume 3 main release which is expected to be available by month of September. We appreciate your patience until then. 

Arulraj A 



VR Vigneshkumar Ramasamy Syncfusion Team September 24, 2018 06:24 AM UTC

Hi Maciej, 
 
We are glad to announce that our Essential Studio Volume 3, 2018 release (v16.3.0.21) is rolled out and is available for download under the following link. 
 
 
The mentioned issue with “Sequence contains no elements exception whenUpdateSchedule method is usedissue has been fixed and included in this release. 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Vigneshkumar R 


Loader.
Up arrow icon