Unplanned
Last Updated: 09 Aug 2024 15:55 by Terrence
Terrence
Created on: 09 Aug 2024 15:55
Category: Grid
Type: Bug Report
1
Grid with Enum values throws when restoring the filtered state

I have a filterable Grid with Enum values. I am saving the state in the OnStateChanged so I can then restore it on future page loads (similar to the approach here).

When trying to restore the deserialized state in the OnStateInit, the Grid throws:

Unhandled exception rendering component: Specified cast is not valid.

Reproduction: https://blazorrepl.telerik.com/QSaiaDkq55RfazF402.

===

ADMIN EDIT

===

At the time of writing (UI for Blazor 6.1.0), the Grid only supports int as an underlying type of the Enum values. When the state is deserialized, the Enum values are returned as short and this causes the issue.

To handle the scenario for the time being you can modify the state object before setting it to the Grid. Loop through the filter descriptors in the state and convert the filter value of the columns bound to Enum, so the value type in the state is the supported int.

Here is a basic example: https://blazorrepl.telerik.com/woaCOZlT29E05lpL45.

 

0 comments