SfCalendar is loading very slow

Hi Bernd, 
 
#Regarding SfCalendar is loading very slow 
We could not to replicate the reported scenario from our end. We have prepared the simple sample with given information and tested the sample with android 9 (Honor 9N) device API 28. we have attached the tested sample in the following locations.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CalendarXamarin1501483502
 
 
Please check the sample and let us know if you still facing the same issue? If not, please modify our sample based on your scenario and revert us back with the following details, 
 
·       Issue reproducing video 
·       Share the issue reproduce platforms.

 
It will be helpful for us to check on it and provide you the solution at the earliest.  
 
Regards,
SaiGanesh Sakthivel
 


6 Replies 1 reply marked as answer

BS Bernd Seibold February 25, 2022 05:39 PM UTC

I have a simple CalendarView and want to show the dots for all days with events. The collection is filled OnAppearing of the View. With 1-2 entries everything is ok. But with 8 events it already takes 5 seconds to load. Unfortunately CalendarEventCollection has no constructor to pass a complete list. So a lot of events will be fired. What is the correct way to init the data?

ViewModel:

public CalendarEventCollection CalendarInlineEvents { get; set; } = new CalendarEventCollection();

public async Task Init()

{

ScheduleDayCache = await dataService.LoadScheduleDays();

foreach (var item in ScheduleDayCache)

CalendarInlineEvents.Add( CreateEvent(item) );

}


View:


FirstDayofWeek="1"
InlineViewMode="Agenda"
MaximumEventIndicatorCount="3"
SelectedDate="{Binding SelectedDate}"
ShowInlineEvents="False"
ShowNavigationButtons="True"
ViewMode="MonthView"
SelectionChangedCommand="{Binding SelectedDateChangedCommand}">



Version SfCalendar: 19.1.0.69



BS Bernd Seibold February 26, 2022 01:45 AM UTC

Sorry, forgot to mention the platform. Android seems ok but UWP is slow. I have also attached a sample project

And is there a reason why there is no constructor to pass a complete list to the CalendarEventCollection?


Attachment: CalendarSample_273ce806.zip



SS SaiGanesh Sakthivel Syncfusion Team February 28, 2022 10:51 AM UTC

Hi Bernd, 
 
#Regarding SfCalendar is loading very slow. 
We suggest you call the SuspendAppointmentUpdate method and ResumeAppointmentUpdate method when adding the new appointments to the collection. SuspendAppointmentUpdate method will suspend appointment UI rendering until you resume it when large number of data added dynamically in schedule DataSource to avoid each time updating UI when collection changes. After data added dynamically in schedule, you can call ResumeAppointmentUpdate to update the appointment UI rendering. Please refer to the following code snippet for your reference. 
 
Code snippet 
internal void Init() 
{ 
    calendar.SuspendAppointmentUpdate(); 
    for (int i = 0; i < 8; i++) 
    { 
        CalendarInlineEvent event2 = new CalendarInlineEvent(); 
        event2.StartTime = DateTime.Now; 
        event2.EndTime = DateTime.Now.AddHours(i); 
        event2.Subject = i.ToString(); 
        event2.Color = Xamarin.Forms.Color.AliceBlue; 
        CalendarInlineEvents.Add(event2); 
    } 
    calendar.ResumeAppointmentUpdate(); 
} 
 
Please refer to the tested sample in the following locations. 
 
Please let us know if you have any concerns. 
 
Regards,
SaiGanesh Sakthivel



BS Bernd Seibold March 2, 2022 01:45 AM UTC

Hi,

your sample is working. But in my app the performance is not improved. I still check the differences. Maybe because the calendar is used in a more complex layout (with bottom navigation/tabbedpage)

Generally I do not like the solution. I have to add code to the view or pass a control to my viewmodel. This breaks MVVM.

So why do you hide the constructor

public ObservableCollection(IEnumerable<T> collection);

This would be a better solution.

Best Regards

Bernd



BS Bernd Seibold replied to Bernd Seibold March 2, 2022 02:03 AM UTC

Setting it isVisible=false did the trick.


 protected async override void OnAppearing()

 {.....

progressBar.IsVisible = true;

calendar.IsVisible = false;

await ViewModel.Init();

progressBar.IsVisible = false;

calendar.IsVisible = true;

.....


The progressBar is not displayed at all because the loading is very fast as long as the calendar is invisible.


Marked as answer

SS SaiGanesh Sakthivel Syncfusion Team March 2, 2022 07:17 AM UTC

Hi Bernd, 
 
We are glad to know that you have achieved your requirement. Please let us know if you need any further assistance.  
 
Regards,
SaiGanesh Sakthivel
 


Loader.
Up arrow icon