You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an enum filter in DataGrid, if we use Display Attribute to enums as in the example below, instead of the names we give, it says "Distributor".
The reason for the error is the GetDisplayName method in TypeExtensions.cs.
To fix it, writing name = attr?.Name?? name; instead of name = attr?.GetName() ?? name; fixes the problem.
Enum Test
{
[Display(Name = nameof(BackEnd.CompanyTypeDistributor), ResourceType = typeof(BackEnd))]
Distributor = 1,
}
public static string? GetDisplayName(this Type type, string? name)
{
if (name != null)
{
var attr = type!.GetMember(name).FirstOrDefault()?.GetCustomAttribute();
name = attr?.GetName() ?? name;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When using an enum filter in DataGrid, if we use Display Attribute to enums as in the example below, instead of the names we give, it says "Distributor".
The reason for the error is the GetDisplayName method in TypeExtensions.cs.
To fix it, writing name = attr?.Name?? name; instead of name = attr?.GetName() ?? name; fixes the problem.
Enum Test
{
[Display(Name = nameof(BackEnd.CompanyTypeDistributor), ResourceType = typeof(BackEnd))]
Distributor = 1,
}
public static string? GetDisplayName(this Type type, string? name)
{
if (name != null)
{
var attr = type!.GetMember(name).FirstOrDefault()?.GetCustomAttribute();
name = attr?.GetName() ?? name;
}
return name;
}
Beta Was this translation helpful? Give feedback.
All reactions