[PR #455] [MERGED] Add Display Attribute and localization for Enum Filter #2183

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

📋 Pull Request Information

Original PR: https://github.com/radzenhq/radzen-blazor/pull/455
Author: @vertonghenb
Created: 5/11/2022
Status: Merged
Merged: 5/12/2022
Merged by: @enchev

Base: masterHead: enum-display-attribute


📝 Commits (2)

  • f1f7124 Add Display Attribute and localization
  • ee7f09e Fix simple mode and use actual value not string.

📊 Changes

4 files changed (+74 additions, -14 deletions)

View changed files

Radzen.Blazor/Extensions.cs (+40 -0)
📝 Radzen.Blazor/RadzenDataGrid.razor (+2 -2)
📝 Radzen.Blazor/RadzenDataGridHeaderCell.razor (+2 -2)
📝 RadzenBlazorDemos/Pages/DataGridColumnEnumFilterPage.razor (+30 -10)

📄 Description

Continues on PR #435
We can now use the built-in Display attribute to manipulate the Enum Description. For example:

public enum ColorType
{
        Red,
        Green,
        Blue,
        [Display(Description = "Almond Green")]
        AlmondGreen,
        [Display(Description = "Amber Gray")]
        AmberGray,
        [Display(Description = "Apple Blue... ")]
        AppleBlueSeaGreen,
        //[Display(Description = "Miss", ResourceType = typeof(ResourceFile)] localization example
        [Display(Description = "Azure")]
        AzureBlue,
}

This PR does not introduce breaking changes, it's an opt-in to localise the enum values in the filter or give a nicer description while keeping the API simple.

<RadzenDataGridColumn TItem="Employee" Property="Color" Title="Favorite Color (Display Attribute in Filter)" />
Screenshot 2022-05-11 at 15 11 35

🔄 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/455 **Author:** [@vertonghenb](https://github.com/vertonghenb) **Created:** 5/11/2022 **Status:** ✅ Merged **Merged:** 5/12/2022 **Merged by:** [@enchev](https://github.com/enchev) **Base:** `master` ← **Head:** `enum-display-attribute` --- ### 📝 Commits (2) - [`f1f7124`](https://github.com/radzenhq/radzen-blazor/commit/f1f7124e3522a3c7b6b99356b5322454218c2749) Add Display Attribute and localization - [`ee7f09e`](https://github.com/radzenhq/radzen-blazor/commit/ee7f09e2c86f31ca7d9e01845a27a5cac8b245a3) Fix simple mode and use actual value not string. ### 📊 Changes **4 files changed** (+74 additions, -14 deletions) <details> <summary>View changed files</summary> ➕ `Radzen.Blazor/Extensions.cs` (+40 -0) 📝 `Radzen.Blazor/RadzenDataGrid.razor` (+2 -2) 📝 `Radzen.Blazor/RadzenDataGridHeaderCell.razor` (+2 -2) 📝 `RadzenBlazorDemos/Pages/DataGridColumnEnumFilterPage.razor` (+30 -10) </details> ### 📄 Description Continues on PR #435 We can now use the built-in Display attribute to manipulate the Enum Description. For example: ```cs public enum ColorType { Red, Green, Blue, [Display(Description = "Almond Green")] AlmondGreen, [Display(Description = "Amber Gray")] AmberGray, [Display(Description = "Apple Blue... ")] AppleBlueSeaGreen, //[Display(Description = "Miss", ResourceType = typeof(ResourceFile)] localization example [Display(Description = "Azure")] AzureBlue, } ``` This PR does not introduce breaking changes, it's an opt-in to localise the enum values in the filter or give a nicer description while keeping the API simple. ```razor <RadzenDataGridColumn TItem="Employee" Property="Color" Title="Favorite Color (Display Attribute in Filter)" /> ``` <img width="1637" alt="Screenshot 2022-05-11 at 15 11 35" src="https://user-images.githubusercontent.com/10981553/167858143-4fc016bc-6582-47d2-8e36-6872c93e0237.png"> --- <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:17:38 +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#2183