-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QuickGrid] Set column title by using DataAnnotations.DisplayAttribute #47155
Comments
@mkArtakMSFT this is incorrectly labeled as 'area-identity'. Can you re-label as 'area-blazor'? And add label 'feature-blazor-quickgrid'. Thanks! |
@vnbaaij it's not clear what the specific ask is. |
Hi @vnbaaij. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Hi Artak, I'm proposing an extra/alternative way to specify a @using System.ComponentModel.DataAnnotations
<FluentDataGrid RowsData="@people">
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
<PropertyColumn Property="@(p => p.Name)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
</FluentDataGrid>
@code {
public class Person
{
public Person(int personId, string name, DateOnly birthDate)
{
PersonId = personId;
Name = name;
BirthDate = birthDate;
}
[Display(Name="Identity")]
public int PersonId { get; set; }
[Display(Name = "Full name")]
public string Name { get; set; }
[Display(Name = "Birth date")]
public DateOnly BirthDate { get; set; }
}
IQueryable<Person> people = new[]
{
new Person(10895, "Jean Martin", new DateOnly(1985, 3, 16)),
new Person(10944, "António Langa", new DateOnly(1991, 12, 1)),
new Person(11203, "Julie Smith", new DateOnly(1958, 10, 10)),
new Person(11205, "Nur Sari", new DateOnly(1922, 4, 27)),
new Person(11898, "Jose Hernandez", new DateOnly(2011, 5, 3)),
new Person(12130, "Kenji Sato", new DateOnly(2004, 1, 9)),
}.AsQueryable();
} In contrast to the regular implementation where it looks like this:
By using the DataAnnotations, it would be possible for a developer to localize the grid for different cultures. I'm not proposing to change the current implementation but to augment it with the described behavior. If we agree on this being a good addition, I could provide a PR for it. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Hello everyone, I just wanted to let you know that I have submitted a pull request for the feature we discussed here. Here is the link: #47993. I would appreciate your feedback and suggestions. Thank you! |
Summary
In the Microsoft.Fast.Components.FluentUI package I'm using a QuickGrid copy that is extended to define a column title by using the
System.ComponentModel.DataAnnotations.DisplayAttribute
on the property you want to display in a column (instead of specifying aTitle
parameter on theTemplateColumn
orPropertyColumn
)Motivation and goals
Order
(and other) propertiesIn scope
Out of scope
Risks / unknowns
Risk is low as the original Title parameter is kept in place. This just offers an alternative way of setting a column's title. Need to document what option gets precedence over the other
Examples
For example code and implementation see the Razor tab at https://brave-cliff-0c0c93310.azurestaticapps.net/DataGrid#column-headers
Alternative approach
We could also use
DisplayName
attribute (fromSystem.ComponentModel
) to be able to specify a title on a property but we would lose the option to read from a resource file with that. Also, this approach would not help with a possible auto generation scenario later (no Order or other properties).The text was updated successfully, but these errors were encountered: