dynamic column

main
Peace 10 months ago
parent d5d15827a7
commit 67a2e4c332
  1. 25
      HelloBlazorServer/HelloBlazorServer/Components/Pages/QGGetStarted.razor

@ -1,6 +1,12 @@
@page "/qggetStarted"
@rendermode RenderMode.InteractiveServer
<p>
Show:
<label><input type="checkbox" @bind="showId" />Id</label>
<label><input type="checkbox" @bind="showAction" />Action</label>
</p>
<div>
<QuickGrid Items="@people">
<TemplateColumn Title="Person" SortBy="@sortByName">
@ -11,21 +17,30 @@
</nobr>
</div>
</TemplateColumn>
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
@if (showId)
{
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
}
<PropertyColumn Property="@(p => p.FirstName)" Sortable="true" />
<PropertyColumn Property="@(p => p.LastName)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
<PropertyColumn Title="Age in years" Property="@(c => ComputeAge(c.BirthDate))" Sortable="true" Align="Align.Right" />
<TemplateColumn Title="Action">
<button @onclick="@(() => Hire(context))">Hire</button>
<button @onclick="@(() => Fire(context))">Fire</button>
</TemplateColumn>
@if (showAction)
{
<TemplateColumn Title="Action">
<button @onclick="@(() => Hire(context))">Hire</button>
<button @onclick="@(() => Fire(context))">Fire</button>
</TemplateColumn>
}
</QuickGrid>
</div>
<p><strong>@message</strong></p>
@code {
bool showAction;
bool showId;
string message = string.Empty;
record Person(int PersonId, string Name, DateOnly BirthDate, string FlagCode)

Loading…
Cancel
Save