I have a Scheduler component that was working a couple of weeks ago. Maybe I changed something, maybe I updated the control, but it's not now working. We're using to schedule fields at a local park.
When viewing the scheduler with horizontal grouping, it displays correctly the first time, but if you click to change the day or view from to Week or Month you get this errror in the console:
Error: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.FilterDayCollection(List`1 eventCollection)
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.FilterCollection(List`1 eventCollection)
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.CallStateHasChanged(List`1 eventCollection, List`1 cellAttributes, String eventWrapperClass)
at Syncfusion.Blazor.Schedule.Internal.VerticalView`1.DataReady(IEnumerable`1 result, Nullable`1 date)
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.DataManagerSuccess(IEnumerable`1 result)
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.RefreshDataManager()
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.RefreshDataManager()
at Syncfusion.Blazor.Schedule.Internal.VerticalView`1.OnParametersSetAsync()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
If I remove the Grouping code, the scheduler appears to work fine.
I have attached a sample project (please forgive any major readability issues, I tried to take my formerly working project and strip all the business logic out to distill it to the most basic project I could that shows the error.)
Any idea on what might be going on here?
Thanks!
Hi Chris,
We have validated your reported query and confirmed this as defect at our end. So, we have logged the bug report which can be tracked from the following link.
The fix for this defect will be included in our upcoming patch release which is expected to be rolled out by the end of June. We would appreciate your valuable patience until then.
Regards,
Satheesh Kumar B
Hi Chris,
We are glad to announce that our weekly patch release v20.1.61 has been rolled out successfully. In this release, the exception on changing views or days with resource grouping in vertical views has been fixed. As a result, we recommend you upgrade to the latest version of our Syncfusion package to avail of those changes.
Kindly check the reported defect in the latest version and get back to us if you need any further assistance.
Regards,
I am getting a similar error in 20.4.0.43
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.Collections.Generic.List`1[[Syncfusion.Blazor.Schedule.Internal.CellData, Syncfusion.Blazor.Schedule, Version=20.4.0.43, Culture=neutral, PublicKeyToken=null]].get_Item(Int32 index)
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.<FilterDayCollection>d__17[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.<FilterCollection>d__16[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.VerticalEventTable`1.<CallStateHasChanged>d__15[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.VerticalView`1.<DataReady>d__55[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.<DataManagerSuccess>d__26[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.<RefreshDataManager>d__24[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.EventBase`1.<RefreshDataManager>d__24[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Syncfusion.Blazor.Schedule.Internal.VerticalView`1.<OnParametersSetAsync>d__68[[PyramedAnywhere.UI.Code.Data.Appointment.AppointmentSchedulingModel, PyramedAnywhere.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
The data does load after the exception is thrown and the Events are grouped as expected. If I comment out the grouping I do not get the exception.
Thanks
MB
I took this example from your docs to demonstrate the issue:
https://blazor.syncfusion.com/documentation/scheduler/resources#vertical-resource-view
When data is loaded synchronously the sample works fine, when data is loaded asynchronously in OnInitialized you will see the error.
@page "/schedissue"
<SfSchedule TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate">
<ScheduleGroup Resources="@Resources"></ScheduleGroup>
<ScheduleResources>
<ScheduleResource TItem="ResourceData" TValue="int" DataSource="@RoomData" Field="RoomId" Title="Room" Name="Rooms" TextField="RoomText" IdField="Id" ColorField="RoomColor" AllowMultiple="false"></ScheduleResource>
<ScheduleResource TItem="ResourceData" TValue="int[]" DataSource="@OwnersData" Field="OwnerId" Title="Owner" Name="Owners" TextField="OwnerText" IdField="Id" GroupIDField="OwnerGroupId" ColorField="OwnerColor" AllowMultiple="true"></ScheduleResource>
</ScheduleResources>
<ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.WorkWeek"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
<ScheduleView Option="View.Agenda"></ScheduleView>
</ScheduleViews>
</SfSchedule>
@code {
DateTime CurrentDate = new DateTime(2023, 6, 1);
public string[] Resources { get; set; } = { "Rooms", "Owners" };
public List<ResourceData> RoomData = new();
public List<ResourceData> OwnersData { get; set; } = new();
List<AppointmentData> DataSource = new();
//NO Error when data is loaded synchronously
//protected override void OnInitialized()
//{
// RoomData = new List<ResourceData>
// {
// new ResourceData { RoomText = "ROOM 1", Id = 1, RoomColor = "#cb6bb2" },
// new ResourceData { RoomText = "ROOM 2", Id = 2, RoomColor = "#56ca85" }
// };
// OwnersData = new List<ResourceData>
// {
// new ResourceData { OwnerText = "Nancy", Id = 1, OwnerGroupId = 1, OwnerColor = "#ffaa00" },
// new ResourceData { OwnerText = "Steven", Id = 2, OwnerGroupId = 2, OwnerColor = "#f8a398" },
// new ResourceData { OwnerText = "Michael", Id = 3, OwnerGroupId = 1, OwnerColor = "#7499e1" }
// };
// DataSource = new List<AppointmentData>
// {
// new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2023, 6, 1, 9, 30, 0), EndTime = new DateTime(2023, 6, 1, 11, 0, 0), OwnerId = 1, RoomId = 1 }
// };
//}
//Simulate data being Asynchronously
protected override async Task OnInitializedAsync()
{
await Task.Run(() =>
{
RoomData = new List<ResourceData>
{
new ResourceData { RoomText = "ROOM 1", Id = 1, RoomColor = "#cb6bb2" },
new ResourceData { RoomText = "ROOM 2", Id = 2, RoomColor = "#56ca85" }
};
OwnersData = new List<ResourceData>
{
new ResourceData { OwnerText = "Nancy", Id = 1, OwnerGroupId = 1, OwnerColor = "#ffaa00" },
new ResourceData { OwnerText = "Steven", Id = 2, OwnerGroupId = 2, OwnerColor = "#f8a398" },
new ResourceData { OwnerText = "Michael", Id = 3, OwnerGroupId = 1, OwnerColor = "#7499e1" }
};
DataSource = new List<AppointmentData>
{
new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2023, 6, 1, 9, 30, 0), EndTime = new DateTime(2023, 6, 1, 11, 0, 0), OwnerId = 1, RoomId = 1 }
};
});
}
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public string Location { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
public Nullable<int> RecurrenceID { get; set; }
public int OwnerId { get; set; }
public int RoomId { get; set; }
}
public class ResourceData
{
public int Id { get; set; }
public string RoomText { get; set; }
public string RoomColor { get; set; }
public string OwnerText { get; set; }
public string OwnerColor { get; set; }
public int OwnerGroupId { get; set; }
}
}
Hi Matt
We suggest you render the Scheduler once the resources data fully load by checking the conditions as shown below to resolve the problem.
[Index.razor]
|
@if (RoomData != null && RoomData.Count > 0 && OwnersData != null && OwnersData.Count > 0) { <SfSchedule TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate"> <ScheduleGroup Resources="@Resources"></ScheduleGroup> <ScheduleResources> <ScheduleResource TItem="ResourceData" TValue="int" DataSource="@RoomData" Field="RoomId" Title="Room" Name="Rooms" TextField="RoomText" IdField="Id" ColorField="RoomColor" AllowMultiple="false"></ScheduleResource> <ScheduleResource TItem="ResourceData" TValue="int[]" DataSource="@OwnersData" Field="OwnerId" Title="Owner" Name="Owners" TextField="OwnerText" IdField="Id" GroupIDField="OwnerGroupId" ColorField="OwnerColor" AllowMultiple="true"></ScheduleResource> </ScheduleResources> <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings> <ScheduleViews> <ScheduleView Option="View.Day"></ScheduleView> <ScheduleView Option="View.Week"></ScheduleView> <ScheduleView Option="View.WorkWeek"></ScheduleView> <ScheduleView Option="View.Month"></ScheduleView> <ScheduleView Option="View.Agenda"></ScheduleView> </ScheduleViews> </SfSchedule> } |
Regards,
Vijay Ravi
Thank you for your reply,
That solution did occur to me, but in our use case, we want the calendar to appear before the user selects any resources. We could display an empty calendar in the else clause of your solution to get the desired visual effect.
However, the issue I reported does seem like a bug.
Hi Matt
We confirmed your reported problem with "data is loaded asynchronously in OnInitialized" as a bug and logged the defect report. The fix for this defect will be included in our upcoming weekly patch release, which is expected to be rolled out by the first week of February 2023. You can track the status of the fix at the following link:
Disclaimer: The inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Vijay Ravi
Matt, The fix for the issue “Exception is thrown when loading resource data asynchronously in OnInitialized lifecycle” has been included in our SP release 20.4.48. Upgrade to the latest version to resolve the issue.