[PR #1282] [MERGED] Added support for translation of DisplayAttribute Description properties in RadzenDataGrid Enum filters #2643

Open
opened 2026-01-29 18:19:48 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/1282
Author: @decimvs
Created: 12/11/2023
Status: Merged
Merged: 12/13/2023
Merged by: @enchev

Base: masterHead: master


📝 Commits (1)

  • 6c175f3 feature: added support to define a custom function to be called when datagrid enum filter is rendering enum filter menu to display a translated text by calling a custom function. It allows to use alternative I18N stacks.

📊 Changes

3 files changed (+16 additions, -5 deletions)

View changed files

📝 Radzen.Blazor/Extensions.cs (+8 -4)
📝 Radzen.Blazor/RadzenDataGrid.razor.cs (+7 -0)
📝 Radzen.Blazor/RadzenDataGridHeaderCell.razor (+1 -1)

📄 Description

In the RadzenDataGrid Enum filters there isn't the possibilty to intercept the render of the text in the options select menu. This causes that the texts in the DisplayAttribute Descriptions don't get translated if you use a different I18N stack than .NET's default. The aim of this feature is to offer the possibility to the developer to define a function that will be called for each text defined in a DisplayAttribute in addition to the Enum.ToString(). Radzen.Blazor is well I18N oriented, but in my opinion was lacking of this kind of translation posibility.
This principle can be exported to other kinds of components with a similar problematic.

The principle is simple: we define a property in the RadzenDataGrid component that brings the possibility to define a function Func<string, string>. In the RadzenDataGridHeaderCell component the function is passed to the Extensions.EnumAsKeyValuePair() function that passes it to the Extensions.GetDisplayDescription() that finally will call this function if it is not null. It lets the developer to define a custom function, in my case _T(string text) that returns a string containing the translation of the passed text.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/radzenhq/radzen-blazor/pull/1282 **Author:** [@decimvs](https://github.com/decimvs) **Created:** 12/11/2023 **Status:** ✅ Merged **Merged:** 12/13/2023 **Merged by:** [@enchev](https://github.com/enchev) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`6c175f3`](https://github.com/radzenhq/radzen-blazor/commit/6c175f3d3bd30101edbbd0f2613e2b30255d3a45) feature: added support to define a custom function to be called when datagrid enum filter is rendering enum filter menu to display a translated text by calling a custom function. It allows to use alternative I18N stacks. ### 📊 Changes **3 files changed** (+16 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `Radzen.Blazor/Extensions.cs` (+8 -4) 📝 `Radzen.Blazor/RadzenDataGrid.razor.cs` (+7 -0) 📝 `Radzen.Blazor/RadzenDataGridHeaderCell.razor` (+1 -1) </details> ### 📄 Description In the RadzenDataGrid Enum filters there isn't the possibilty to intercept the render of the text in the options select menu. This causes that the texts in the DisplayAttribute Descriptions don't get translated if you use a different I18N stack than .NET's default. The aim of this feature is to offer the possibility to the developer to define a function that will be called for each text defined in a DisplayAttribute in addition to the Enum.ToString(). Radzen.Blazor is well I18N oriented, but in my opinion was lacking of this kind of translation posibility. This principle can be exported to other kinds of components with a similar problematic. The principle is simple: we define a property in the RadzenDataGrid component that brings the possibility to define a function `Func<string, string>`. In the RadzenDataGridHeaderCell component the function is passed to the `Extensions.EnumAsKeyValuePair()` function that passes it to the `Extensions.GetDisplayDescription()` that finally will call this function if it is not null. It lets the developer to define a custom function, in my case `_T(string text)` that returns a string containing the translation of the passed `text`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 18:19:48 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#2643