DataGridSettings doesn't store the RadzenDataGridColumn Type property #976

Open
opened 2026-01-29 17:47:11 +00:00 by claunia · 0 comments
Owner

Originally created by @tpc-dsc on GitHub (Sep 6, 2023).

Describe the bug
The RadzenDataGridColumn Type property is not stored when saving and loading DataGridSettings. This is an issue if the Type is something less primitive, such as an IEnumerable<MyEnum>.

To Reproduce
Steps to reproduce the behavior:

  1. Using the blazor.radzen DataGrid filter example, set Type="typeof(IEnumerable<string>)" and FilterOperator="FilterOperator.Contains".
  2. Store the values locally using the blazor.radzen DataGrid save/load settings example.
  3. Select any two values from the filter menu, and check the column FilterValue is an array in local browser storage.
  4. Refresh the page and you'll see an error message such as: "No applicable method 'Contains' exists in type 'String'"".

Expected behavior
Custom RadzenDataGridColumn Types should be stored with DataGridSettings for deserialization.

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome and Firefox
  • "Radzen.Blazor" Version="4.15.7"

Additional context
The workaround is to add a custom conversion of the DataGridSettings FilterValue JsonElement to IList<MyType>.

var setting = settings?.Columns?.Where(c => c.Property == "MyProperty").FirstOrDefault();
if (setting?.FilterValue is JsonElement jsonElement)
	setting.FilterValue = JsonSerializer.Deserialize<IList<MyType>>(jsonElement.GetRawText());
Originally created by @tpc-dsc on GitHub (Sep 6, 2023). **Describe the bug** The RadzenDataGridColumn Type property is not stored when saving and loading DataGridSettings. This is an issue if the Type is something less primitive, such as an `IEnumerable<MyEnum>`. **To Reproduce** Steps to reproduce the behavior: 1. Using the [blazor.radzen DataGrid filter example](https://blazor.radzen.com/datagrid-advanced-filter), set `Type="typeof(IEnumerable<string>)"` and `FilterOperator="FilterOperator.Contains"`. 2. Store the values locally using the [blazor.radzen DataGrid save/load settings example](https://blazor.radzen.com/datagrid-save-settings-loaddata). 3. Select any two values from the filter menu, and check the column FilterValue is an array in local browser storage. 4. Refresh the page and you'll see an error message such as: "No applicable method 'Contains' exists in type 'String'"". **Expected behavior** Custom RadzenDataGridColumn Types should be stored with DataGridSettings for deserialization. **Desktop (please complete the following information):** - OS: Windows - Browser Chrome and Firefox - "Radzen.Blazor" Version="4.15.7" **Additional context** The workaround is to add a custom conversion of the DataGridSettings FilterValue JsonElement to `IList<MyType>`. ```cs var setting = settings?.Columns?.Where(c => c.Property == "MyProperty").FirstOrDefault(); if (setting?.FilterValue is JsonElement jsonElement) setting.FilterValue = JsonSerializer.Deserialize<IList<MyType>>(jsonElement.GetRawText()); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#976