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.
[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 { get; set; }
public string EndDate { get; set; }
}
|
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.