DataGrid ungrouping in virtualized mode throws error

I am getting an error when I try to ungroup (after having grouped a using a column). When I click the "X" I see this error being logged:

System.InvalidOperationException: Failed to compare two elements in the array.
---> System.ArgumentException: At least one object must implement IComparable.
at System.Collections.Comparer.Compare(Object a, Object b)
at System.Linq.EnumerableSorter`2.CompareAnyKeys(Int32 index1, Int32 index2)
at System.Collections.Generic.ArraySortHelper`1.SwapIfGreater(Span`1 keys, Comparison`1 comparer, Int32 i, Int32 j)
at System.Collections.Generic.ArraySortHelper`1.PickPivotAndPartition(Span`1 keys, Comparison`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.IntroSort(Span`1 keys, Int32 depthLimit, Comparison`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.IntrospectiveSort(Span`1 keys, Comparison`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.Sort(Span`1 keys, Comparison`1 comparer)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize`1.BuildRenderTree(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

The exception is not thrown in my code nor in the DataGrid's code.

When virtualization is OFF, ungrouping works OK and no errors are logged.

I have tested using the demos and it seems to be working OK without any errors.

I'd appreciate some advise as to how can I fix this?

If you can prepare for us small example demonstrating the problem we will be able to provide more info. It's possible also to attach Radzen.Blazor.csproj to your project and debug the code to check what's causing the exception.

Same exact issue here:

Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Failed to compare two elements in the array.

System.InvalidOperationException: Failed to compare two elements in the array.
 ---> System.ArgumentException: At least one object must implement IComparable.
   at System.Collections.Comparer.Compare(Object a, Object b)
   at System.Linq.EnumerableSorter`2.CompareAnyKeys(Int32 index1, Int32 index2)
   at System.Collections.Generic.ArraySortHelper`1.PickPivotAndPartition(Span`1 keys, Comparison`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.IntroSort(Span`1 keys, Int32 depthLimit, Comparison`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.Sort(Span`1 keys, Comparison`1 comparer)
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Components.Web.Virtualization.Virtualize`1.BuildRenderTree(RenderTreeBuilder builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit '_jmbIjV1ePpF-hFKY18CiE_sB1_FA91hAkUdBlUbFsQ'.

This started happening when I took Blazor Server app that I hadn't worked on for some months and upgraded all nuget packages. Radzen.Blazor 4.29.9

Stephen

I was able to reproduce the problem - fix will be published immediately!

1 Like

Radzen.Blazor 4.30.0 just published.

2 Likes