diff --git a/examples/Demo/Shared/Pages/Lab/IssueTester.razor b/examples/Demo/Shared/Pages/Lab/IssueTester.razor
index 3f0945b4a7..2589c2a7da 100644
--- a/examples/Demo/Shared/Pages/Lab/IssueTester.razor
+++ b/examples/Demo/Shared/Pages/Lab/IssueTester.razor
@@ -1,3 +1,46 @@
@page "/issue-tester"
+@using System.ComponentModel.DataAnnotations
-
+
+
+
+
+
+
+
+@code {
+
+ public enum Positions
+ {
+ employee,
+ [Display(Name = "HR Manager (DA)")]
+ HrManager,
+ [Display(Name = "Project Manager (DA)")]
+ ProjectManager,
+ [Display(Name = "Administrator (DA)")]
+ Administrator
+ }
+
+ public class Employee
+ {
+ [Display(Name = "Id")]
+ public int Id { get; set; }
+ [Required, Display(Name = "Full Name")]
+ public string FullName { get; set; }
+ [Required, Display(Name = "Subdivision")]
+ public string Subdivision { get; set; }
+ [Required, Display(Name = "Position")]
+ public Positions Position { get; set; }
+
+ }
+
+ private List employees = new List
+ {
+ new Employee { Id = 1, FullName = "John Doe", Subdivision = "IT", Position = Positions.employee },
+ new Employee { Id = 2, FullName = "Jane Doe", Subdivision = "HR", Position = Positions.HrManager },
+ new Employee { Id = 3, FullName = "John Smith", Subdivision = "IT", Position = Positions.ProjectManager },
+ new Employee { Id = 4, FullName = "Jane Smith", Subdivision = "HR", Position = Positions.Administrator }
+ };
+
+
+}
diff --git a/src/Core/Components/DataGrid/Columns/PropertyColumn.cs b/src/Core/Components/DataGrid/Columns/PropertyColumn.cs
index d49e556fa9..9c4557b023 100644
--- a/src/Core/Components/DataGrid/Columns/PropertyColumn.cs
+++ b/src/Core/Components/DataGrid/Columns/PropertyColumn.cs
@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.FluentUI.AspNetCore.Components.DataGrid.Infrastructure;
+using Microsoft.FluentUI.AspNetCore.Components.Extensions;
namespace Microsoft.FluentUI.AspNetCore.Components;
@@ -73,7 +74,19 @@ protected override void OnParametersSet()
}
else
{
- _cellTextFunc = item => compiledPropertyExpression!(item)?.ToString();
+ _cellTextFunc = item =>
+ {
+ var value = compiledPropertyExpression!(item);
+
+ if (typeof(TProp).IsEnum)
+ {
+ return (value as Enum)?.GetDisplayName();
+ }
+ else
+ {
+ return value?.ToString();
+ }
+ };
}
_sortBuilder = Comparer is not null ? GridSort.ByAscending(Property, Comparer) : GridSort.ByAscending(Property);
diff --git a/src/Core/Extensions/EnumExtensions.cs b/src/Core/Extensions/EnumExtensions.cs
index b3e4abc33f..fc437c8c73 100644
--- a/src/Core/Extensions/EnumExtensions.cs
+++ b/src/Core/Extensions/EnumExtensions.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Reflection;
namespace Microsoft.FluentUI.AspNetCore.Components.Extensions;
@@ -38,4 +39,11 @@ public static class EnumExtensions
return description;
}
+
+ public static string GetDisplayName(this Enum enumValue)
+ {
+ var memberInfo = enumValue.GetType().GetMember(enumValue.ToString());
+ var displayAttribute = memberInfo[0].GetCustomAttribute();
+ return displayAttribute?.Name ?? enumValue.ToString();
+ }
}