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

Loading…
Cancel
Save