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
{{ message }}
Repository navigation
Populate DisplayAttribute for DataGrid content #2300
public class Employee
{
[Display(Name = "Id")]
public int Id { get; set; }
[Required, Display(Name = "Full Name")]
public Names FullName { get; set; }
[Required, Display(Name = "Subdivision")]
public Subdivision Subdivision { get; set; }
[Required, Display(Name = "Position")]
public Positions Position { get; set; }
[Required, Display(Name = "Status")]
public Status Status { get; set; }
/// <summary>
/// Navigation property
/// </summary>
[Required, ForeignKey("PeoplePartner"), Display(Name = "People Partner")]
public Employee? Partner { get; set; }
[Required, Display(Name = "Out-of-Office Balance")]
public ushort? Balance { get; set; }
}
By adding DisplayAttribute to every enum value, I'm expecting same behavior as headers, but it doesn't.
😯 Current Behavior
Here's how it shows now:
Details
🔦 Context
I have a model, which properties are described by set of enum's, in current version I have to do additional steps to render my enums values as expected, instead of using same logic, as implemented for column headers.
Internally a Func<TGridItem, string?>? is defined to get the actual cell text (value) as a string. This is created from the expression put in in the PropertyColumn which is then converted to a string. I don't see a way to intercept/interrupt that step to do some additional work.
Internamente a Func<TGridItem, string?>?viene definito per ottenere il testo effettivo della cella (valore) come stringa. Questo viene creato dall'espressione inserita nella PropertyColumnche viene poi convertita in una stringa. Non vedo un modo per intercettare/interrompere quel passaggio per svolgere del lavoro aggiuntivo.
in this line
Check type is enum and get valur form attribute
in this line Check type is enum and get value from attribute
How?
varvalue=compiledPropertyExpression!(item);varvalueTxt="";if(typeof(TProp).IsEnum()){....//get value from attribute like https://github.com/microsoft/fluentui-blazor/blob/3cf069c03d9046c61703432a03aae62c14daf42a/src/Core/Extensions/EnumExtensions.cs#L15//use reflection// value to enumvalue// enumvalue.GetDescription()...}else{valueTxt=value?.ToString();}
Activity
vnbaaij commentedon Jul 1, 2024
I'm afraid this is currently not possible.
Internally a
Func<TGridItem, string?>?is defined to get the actual cell text (value) as a string. This is created from the expression put in in thePropertyColumnwhich is then converted to a string. I don't see a way to intercept/interrupt that step to do some additional work.franklupo commentedon Jul 1, 2024
in this line
Check type is enum and get valur form attribute
vnbaaij commentedon Jul 1, 2024
How?
franklupo commentedon Jul 1, 2024
vnbaaij commentedon Jul 1, 2024
But that piece of original code does not return the value. It returns the function to invoke to get the value
Daniele Corsini (@franklupo) Are you on Discord? We can have more direct chat there...
franklupo commentedon Jul 1, 2024
which link?
vnbaaij commentedon Jul 1, 2024
Find us at to https://discord.gg/M5cBTfp6J2