Scheduler - Display bug with recurring events & Date Navigate

I am using dynamic resources based on the events for the current range. IE, November is loaded on the Scheduler so get the events for November and only display the resource groups for those events. 
If I am on November and I navigate to December and one of the resource groups for December only has Recurring events, none of the events will be displayed (But the resource groups do!).
You can replicate the issue on the attached sample.

For some reason, if you navigate from January to December (Instead of November -> December) the issue doesn't seem to occur.
Similarly, if the recurring event that is in December actually starts in November, the issue also doesn't seem to occur. 

I have tried calling Scheduler.RefreshEventsAsync after the DateNavigate has completed inside OnAfterRender but that did not fix the issue (And that wouldn't be a permanent solution even if it did work!)

Thanks in advance, Lee.


Attachment: Schedule__Delete_worker_project_combo_no_events_on_date_nav_4bf5aaa6.zip

3 Replies

VD Vinitha Devi Murugan Syncfusion Team November 10, 2021 10:51 AM UTC

Hi Lee, 
 
Greetings from Syncfusion Support. 
 
We have validated your reported query “recurrence events not fetching properly, if the parent event not present in current view range” at our end. To get the recurrence events of a date range, we need to parse the recurrence rule using recurrence helper file like below. Please refer this kb to know more about how to parse recurrence rule at server end. 
 
       [HttpPost]  
        public List<ScheduleEvent> LoadData([FromBody]Params param)  
        {  
            var data = _context.ScheduleEvents.ToList(); // get events from database 
  
            DateTime startdate = DateTime.Today;  
            DateTime enddate = startdate.AddDays(1);  
            List<ScheduleEvent> appCollection = new List<ScheduleEvent>();  
            for (var i = 0; i < data.Count; i++)  
            {  
                var app = data[i];  
                if (data[i].RecurrenceRule != null)  // If recurrene event generate occurrence from parent 
                {  
                    TimeSpan diff = app.EndTime.Subtract(app.StartTime);  
                    var recurrenceRule = data[i].RecurrenceRule;  
                    TimeSpan startDiff;  
                    var dateCollection = RecurrenceHelper.GetRecurrenceDateTimeCollection(recurrenceRule, DateTime.Now); // Here we generated occurrence from recurrence using recurrence helper file 
                    foreach (var date in dateCollection)  
                    {  
                        startDiff = app.StartTime.Subtract(date);  
                        break;  
                    }  
                    foreach (var date in dateCollection)  
                    {  
                        var start = date.Add(startDiff);  
                        var end = start.Add(diff);  
                        appCollection.Add(new ScheduleEvent { Subject = app.Subject, StartTime = start, EndTime = end, CategoryId = app.CategoryId, Description = app.Description, IsAllDay = app.IsAllDay, RecurrenceRule = app.RecurrenceRule, Location = app.Location, ProjectId = app.ProjectId, StartTimezone = app.StartTimezone, EndTimezone = app.EndTimezone, Id = app.Id });  
                    }  
                }  
                else // If normal events directly add it in to app collection 
                {  
                    appCollection.Add(app);  
                }  
            }  
            // Here we filter the today appointment from the appCollection 
            var todayAppointmentCollection = appCollection.Where(app => (app.StartTime >= startdate && app.StartTime <= enddate)).ToList();  
            Console.WriteLine(todayAppointmentCollection); // Now the today appointment available in todayAppointemntCollection variable.  
            return data;  
        }  
  
  
        public class Params  
        {  
            public string StartDate { getset; }  
            public string EndDate { getset; }  
        }  
 
 
Also, we already discussed the same query in below forum. Please refer it. 
 
  
Note: We could not able to run your shared project. 
 
Kindly try with the above solution and get back to us if you need any further assistance 
 
Regards, 
Vinitha 



LS Lee Stevens November 10, 2021 11:28 AM UTC

Hi Vinitha,


I have downloaded the attached sample and had an issue with the length of the directory. I've reuploaded the sample with a shorter name, works fine for me now.


The issue is not with getting the recurring events or calculating the dates, all sorted on that front.

The issue is that the recurring events are causing a display issue when navigating to a new date range.

I have attached two screenshots, one is where the issue occurs and no events are displayed, the other is the same recurring event but displayed correctly.


Apologies if I wasn't clear enough before.



If I start the attached sample and use the navigation arrows on the scheduler control to change to December, I am presented with a blank calendar.

This doesn't always occur, but it occurs most of the time. If I restart the app, it will do the same.



Thanks again, Lee.


No events.png

With events.png


Attachment: Scheduler__Recurrence_Bug_334e8bf0.zip


VD Vinitha Devi Murugan Syncfusion Team November 12, 2021 05:54 AM UTC

Hi Lee, 
 
Thanks for your update. 
 
We have validated your reported issue at our end with your shared sample and we could able to reproduce your reported issue. To overcome this we suggest you to use StateHasChanged method in LoadEvent method like below.  We have shared the working sample sample for your reference.  
 
 
Calendar.razor 
private async Task LoadEvents() 
{ 
    var events = await CalendarDataFactory.GetData(CurrentViewFrom, CurrentViewTo); 
 
    Projects = (from e in events.GroupBy(x => new { x.ProjectId, x.ProjectName }) 
                    select new ProjectData() 
    { 
        ProjectId = e.Key.ProjectId, 
            ProjectName = e.Key.ProjectName 
    }).ToList(); 
 
    UserProjects = (from e in events.GroupBy(x => new { x.WorkerId, x.WorkerName, x.ProjectId, x.ProjectName }) 
                        select new UserProjectData() 
    { 
        ProjectId = e.Key.ProjectId, 
            WorkerId = e.Key.WorkerId, 
            WorkerName = e.Key.WorkerName, 
            ProjectName = e.Key.ProjectName 
    }).ToList(); 
 
    //the events and groups are correctly being populated at this point 
    StateHasChanged(); //We can change the property value dynamically by manually calling the StateHasChanged() method inside public event of Blazor Calendar component only. This method notifies the component that its state has changed and queues a re-render. 
    CurrentEvents = events; 
    StateHasChanged(); 
} 
 
Kindly try with the above sample and get back to us if you need any further assistance. 
 
Regards, 
Vinitha 
 

Loader.
Up arrow icon