Skip to content

Commit 86d6f90

Browse files
authored
Make QuickGrid section "Display name support" use correct way to determine display name (#34479)
1 parent 772dde8 commit 86d6f90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

aspnetcore/blazor/components/quickgrid.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ However, managing column titles (names) from bound model properties is usually a
297297
public DateTime ReleaseDate { get; set; }
298298
```
299299

300-
To enable the `QuickGrid` component to use the <xref:System.ComponentModel.DataAnnotations.DisplayAttribute.Name?displayProperty=nameWithType>, subclass <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2> either in the component or in a separate class:
300+
To enable the `QuickGrid` component to use the <xref:System.ComponentModel.DataAnnotations.DisplayAttribute.Name?displayProperty=nameWithType> property, subclass <xref:Microsoft.AspNetCore.Components.QuickGrid.PropertyColumn`2>, either in the component or in a separate class. Call the <xref:System.ComponentModel.DataAnnotations.DisplayAttribute.GetName%2A> method to return the localized <xref:System.ComponentModel.DataAnnotations.DisplayAttribute.Name?displayProperty=nameWithType> value if an unlocalized <xref:System.ComponentModel.DisplayNameAttribute.DisplayName> ([`[DisplayName]` attribute](xref:System.ComponentModel.DisplayNameAttribute)) doesn't hold the value:
301301

302302
```csharp
303303
public class DisplayNameColumn<TGridItem, TProp> : PropertyColumn<TGridItem, TProp>
@@ -309,7 +309,7 @@ public class DisplayNameColumn<TGridItem, TProp> : PropertyColumn<TGridItem, TPr
309309
var memberInfo = memberExpression.Member;
310310
Title =
311311
memberInfo.GetCustomAttribute<DisplayNameAttribute>().DisplayName ??
312-
memberInfo.GetCustomAttribute<DisplayAttribute>().Name ??
312+
memberInfo.GetCustomAttribute<DisplayAttribute>().GetName() ??
313313
memberInfo.Name;
314314
}
315315

0 commit comments

Comments
 (0)