Blazor Gantt - Error on Duplicate Task Id

Just thought I'd share an error message that I received when using the Blazor Gantt control. It turns out that the problem related to a duplicate Task Id, but it took me a while to work this out from the following message that I received. Hope this helps out someone else.


blazor.server.js:21 [2022-06-05T23:22:59.304Z] Error: System.Collections.Generic.KeyNotFoundException: The specified key 'level' does not exist in the ExpandoObject.
at System.Dynamic.ExpandoObject.System.Collections.Generic.IDictionary.get_Item(String key)
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1.UpdateChildRecords(IDictionary`2& record, String taskId, Int32& level, Int32& index, DataReadyArgs`1 dm, Object parentRecord)
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1.CreateRecords(IEnumerable flatData, DataReadyArgs`1 dm)
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1.ConvertToFlatData(DataReadyArgs`1 dm)
at Syncfusion.Blazor.TreeGrid.SfTreeGrid`1.GetFlatData(IEnumerable dataSource, DataReadyArgs`1 dm, Boolean isRemoteChild, Boolean isGanttRecord)
at Syncfusion.Blazor.Gantt.Internal.TreeGridPane`1.GetGanttFlatData(IEnumerable dataSource)
at Syncfusion.Blazor.Gantt.Internal.TreeGridPane`1.CheckDataBinding(Boolean isDynamic)
at Syncfusion.Blazor.Gantt.Internal.TreeGridPane`1.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

1 Reply

MS Monisha Sivanthilingam Syncfusion Team June 6, 2022 11:06 AM UTC

Hi Greg,


Yes, it is recommended to provide unique values for TaskID for different tasks in order to avoid this kind of errors. This error occurs because, by default the TaskId column acts as a primary key column, and hence requires unique values for it. As you have mentioned, please avoid using duplicate TaskIDs to avoid this errors. We can also avoid this issue by setting the IsPrimaryKey field to any other column.


Reference: https://blazor.syncfusion.com/documentation/gantt-chart/managing-tasks#troubleshoot-editing-works-only-when-primary-key-column-is-defined


Regards,

Monisha.


Loader.
Up arrow icon