RadzenDataGridColumn.SetFilterValue causes InvalidOperationException when called from RadzenDataGridColumn.ClearFilters. #1224

Closed
opened 2026-01-29 17:50:40 +00:00 by claunia · 1 comment
Owner

Originally created by @anatec-deryck on GitHub (Apr 30, 2024).

Describe the bug

Version 4.30.3 crashes with an InvalidOperationException "Unable to set property 'Data' on object of type 'Radzen.Blazor.RadzenDataGrid". This is caused when the FilterType is an (not nullable) enum as ClearFilters calls SetFilterValue(null) and SetFilterValue tries to use cast null to int at line 1034.

To Reproduce

Create a Razor component that uses RadzenDataGrid with a non-nullable column of an enumerated type.
Rendering the component throws an InvalidOperationException caused by a null reference in SetFilterValue.

Expected behavior

The component should render successfully (which works in version 4.30.2).

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome, but is not browser dependent
  • Version: 4.30.3

Additional context

Version 4.30.3 contains a fix to initialize the filter value for an enumerated type with the following three lines of code:

if (PropertyAccess.IsEnum(FilterPropertyType) || (PropertyAccess.IsNullableEnum(FilterPropertyType) && value != null))
{
    value = (int)value;
}

However SetFilterValue is called by ClearFilters passing a value of null. The first test yields true because FilterPropertyType is an enum which results in an attempt to cast value (null) to int.

Originally created by @anatec-deryck on GitHub (Apr 30, 2024). **Describe the bug** Version 4.30.3 crashes with an InvalidOperationException "Unable to set property 'Data' on object of type 'Radzen.Blazor.RadzenDataGrid". This is caused when the `FilterType` is an (not nullable) enum as `ClearFilters` calls `SetFilterValue(null)` and `SetFilterValue` tries to use cast null to int at line 1034. **To Reproduce** Create a Razor component that uses `RadzenDataGrid` with a non-nullable column of an enumerated type. Rendering the component throws an `InvalidOperationException` caused by a null reference in `SetFilterValue`. **Expected behavior** The component should render successfully (which works in version 4.30.2). **Desktop (please complete the following information):** - OS: Windows - Browser: Chrome, but is not browser dependent - Version: 4.30.3 **Additional context** Version 4.30.3 contains a fix to initialize the filter value for an enumerated type with the following three lines of code: ``` if (PropertyAccess.IsEnum(FilterPropertyType) || (PropertyAccess.IsNullableEnum(FilterPropertyType) && value != null)) { value = (int)value; } ``` However `SetFilterValue` is called by `ClearFilters` passing a value of null. The first test yields true because `FilterPropertyType` is an enum which results in an attempt to cast `value` (null) to `int`.
Author
Owner

@anatec-deryck commented on GitHub (Apr 30, 2024):

Duplicate of #1493.

@anatec-deryck commented on GitHub (Apr 30, 2024): Duplicate of #1493.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1224