Bug in packages above 3.18.4 with RadzenDataGrid #479

Closed
opened 2026-01-29 17:37:57 +00:00 by claunia · 2 comments
Owner

Originally created by @ace90210 on GitHub (Jul 24, 2022).

Describe the bug
Note: this bug has been editted and rewritten now i found the underlying issue.

Editted:
When updating Radzen package from 3.18.4 (or earlier) to 3.18.5 or anything newer (i have tried the latest 3.19.9 as well), i have created a simple demo app with the bug but will detail it below from my example:

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: More than one sibling of component 'Radzen.Blazor.RadzenDropDownItem1[System.Object]' has the same key value, '300'. Key values must be unique.
System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenDropDownItem1[System.Object]' has the same key value, '300'. Key values must be unique. at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ThrowExceptionForDuplicateKey(Object key, RenderTreeFrame& frame) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.BuildKeyToInfoLookup(DiffContext diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at

The issue is the use of a RadzenDropdown to list enums that Radzen auto generates the enum filter for. Enums in C# and specifically in this case microsofts official HttpStatusCode, can and do map multiple names to the same value. This means to support enums in C# fully the dropdown also needs to support multiple options with mapping to the same value.

I see a few possible fixes

  1. filter out duplicates, perhaps appending the duplicate descriptions to the existing item in the array
  2. change from dropdowns to another component that supports multiple items mapping to the same underlying value
  3. update the RadzenDropdown to support mapping duplicate mappings

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Create a datagrid with a model that uses the Enum HttpStatusCode'
  2. Open page
  3. See error

I can create a testable version if required but this would take some time so hoping i can get a quick answer first. If requested i will try and reproduce in a sample app.

Expected behavior
The enum filter works with all valid enums, ideally being able to list all descriptions for selection even if there are duplicate underlying values

Screenshots
package 3.18.5
image

package 3.19.9
image

package 3.18.4 (working as evidence the data and code is valid) ignore bad ui this is WIP ui
image

Desktop (please complete the following information):

  • OS: Windows 10 blazor hosted wasm with dotnet 6
  • Browser all but tested in chrome and edge
  • Version latest browsers

Simple Demo of Error Repository

Originally created by @ace90210 on GitHub (Jul 24, 2022). **Describe the bug** Note: this bug has been editted and rewritten now i found the underlying issue. Editted: When updating Radzen package from 3.18.4 (or earlier) to 3.18.5 or anything newer (i have tried the latest 3.19.9 as well), i have created a simple demo app with the bug but will detail it below from my example: `blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: More than one sibling of component 'Radzen.Blazor.RadzenDropDownItem`1[System.Object]' has the same key value, '300'. Key values must be unique. System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenDropDownItem`1[System.Object]' has the same key value, '300'. Key values must be unique. at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ThrowExceptionForDuplicateKey(Object key, RenderTreeFrame& frame) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.BuildKeyToInfoLookup(DiffContext diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at ` The issue is the use of a RadzenDropdown to list enums that Radzen auto generates the enum filter for. Enums in C# and specifically in this case microsofts official HttpStatusCode, can and do map multiple names to the same value. This means to support enums in C# fully the dropdown also needs to support multiple options with mapping to the same value. I see a few possible fixes 1. filter out duplicates, perhaps appending the duplicate descriptions to the existing item in the array 2. change from dropdowns to another component that supports multiple items mapping to the same underlying value 3. update the RadzenDropdown to support mapping duplicate mappings **To Reproduce** Steps to reproduce the behavior: 1. Go to 'Create a datagrid with a model that uses the Enum HttpStatusCode' 5. Open page 6. See error I can create a testable version if required but this would take some time so hoping i can get a quick answer first. If requested i will try and reproduce in a sample app. **Expected behavior** The enum filter works with all valid enums, ideally being able to list all descriptions for selection even if there are duplicate underlying values **Screenshots** package 3.18.5 ![image](https://user-images.githubusercontent.com/2934101/180654075-fb9c1186-d7e5-43da-adde-8c24971c5f65.png) package 3.19.9 ![image](https://user-images.githubusercontent.com/2934101/180654112-a1239195-73b3-4269-8829-a8918bae5651.png) package 3.18.4 (working as evidence the data and code is valid) ignore bad ui this is WIP ui ![image](https://user-images.githubusercontent.com/2934101/180654514-8b2c9800-51ef-4566-8946-fb0093f347da.png) **Desktop (please complete the following information):** - OS: Windows 10 blazor hosted wasm with dotnet 6 - Browser all but tested in chrome and edge - Version latest browsers [Simple Demo of Error Repository](https://github.com/ace90210/RadzenBugExample)
Author
Owner

@ace90210 commented on GitHub (Jul 24, 2022):

Ok so after downloading radzen source code and debugging this appears to be a bug with the microsoft standard HttpStatusCodes enum which had duplicate values i will look at a possible fix and create a PR. enums with Duplicate values values are not forbidden so for now this bug exists for all enums with duplicate enum values so ill leave this bug open

@ace90210 commented on GitHub (Jul 24, 2022): Ok so after downloading radzen source code and debugging this appears to be a bug with the microsoft standard HttpStatusCodes enum which had duplicate values i will look at a possible fix and create a PR. enums with Duplicate values values are not forbidden so for now this bug exists for all enums with duplicate enum values so ill leave this bug open
Author
Owner

@ace90210 commented on GitHub (Jul 24, 2022):

I have tested and created a bugfix for this. The PR is here #543

@ace90210 commented on GitHub (Jul 24, 2022): I have tested and created a bugfix for this. The PR is here #543
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#479