Created
March 16, 2023 16:18
-
-
Save SteveSandersonMS/e487f2159868484d63c89dc8ea219e64 to your computer and use it in GitHub Desktop.
Grid with columns in method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/" | |
@using Microsoft.AspNetCore.Components.QuickGrid | |
<label> | |
<input @bind="@showName" type="checkbox" /> | |
Show name | |
</label> | |
<QuickGrid Items="@people"> | |
@Columns() | |
</QuickGrid> | |
@code { | |
bool showName = true; | |
record Person(int PersonId, string Name, DateOnly BirthDate); | |
private RenderFragment Columns() => @<text> | |
<PropertyColumn TGridItem="Person" TProp="int" Property="@(p => p.PersonId)" Sortable="true" /> | |
@if (showName) | |
{ | |
<PropertyColumn TGridItem="Person" TProp="string" Property="@(p => p.Name)" Sortable="true" /> | |
} | |
<PropertyColumn TGridItem="Person" TProp="DateOnly" Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" /> | |
</text>; | |
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment