|
|
@ -45,8 +45,35 @@ |
|
|
|
<h1><strong>Filtering</strong></h1> |
|
|
|
<h1><strong>Filtering</strong></h1> |
|
|
|
<hr style="border-inline-end-style" /> |
|
|
|
<hr style="border-inline-end-style" /> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="grid"> |
|
|
|
|
|
|
|
<QuickGrid Items="@FilteredMedalTally" Pagination="@pagination"> |
|
|
|
|
|
|
|
<PropertyColumn Property="@(c => c.Name)" Sortable="true" Class="country-name"> |
|
|
|
|
|
|
|
<ColumnOptions> |
|
|
|
|
|
|
|
<div class="search-box"> |
|
|
|
|
|
|
|
<input type="search" autofocus @bind="nameFilter" @bind:event="oninput" placeholder="Country name..."/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</ColumnOptions> |
|
|
|
|
|
|
|
</PropertyColumn> |
|
|
|
|
|
|
|
<PropertyColumn Property="@(c => c.Gold)" Sortable="true" Align="Align.Right" /> |
|
|
|
|
|
|
|
<PropertyColumn Property="@(c => c.Silver)" Sortable="true" Align="Align.Right" /> |
|
|
|
|
|
|
|
<PropertyColumn Property="@(c => c.Bronze)" Sortable="true" Align="Align.Right" /> |
|
|
|
|
|
|
|
<PropertyColumn Property="@(c => c.Total)" Sortable="true" Align="Align.Right"> |
|
|
|
|
|
|
|
<ColumnOptions> |
|
|
|
|
|
|
|
<p>Min: <input type="range" @bind="minMedals" @bind:event="oninput" min="0" max="120" /> <span class="inline-block w-10">@minMedals</span></p> |
|
|
|
|
|
|
|
<p>Max: <input type="range" @bind="maxMedals" @bind:event="oninput" min="0" max="120" /> <span class="inline-block w-10">@maxMedals</span></p> |
|
|
|
|
|
|
|
</ColumnOptions> |
|
|
|
|
|
|
|
</PropertyColumn> |
|
|
|
|
|
|
|
</QuickGrid> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Paginator State="@pagination" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@code { |
|
|
|
@code { |
|
|
|
|
|
|
|
string nameFilter; |
|
|
|
|
|
|
|
int minMedals; |
|
|
|
|
|
|
|
int maxMedals = 120; |
|
|
|
|
|
|
|
|
|
|
|
PaginationState pagination = new PaginationState { ItemsPerPage = 10 }; |
|
|
|
PaginationState pagination = new PaginationState { ItemsPerPage = 10 }; |
|
|
|
IQueryable<MedalTally>? itemsQueryable; |
|
|
|
IQueryable<MedalTally>? itemsQueryable; |
|
|
|
|
|
|
|
|
|
|
@ -55,4 +82,19 @@ |
|
|
|
var items = await Data.GetDataAsync(); |
|
|
|
var items = await Data.GetDataAsync(); |
|
|
|
itemsQueryable = items.AsQueryable(); |
|
|
|
itemsQueryable = items.AsQueryable(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IQueryable<MedalTally> FilteredMedalTally |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var result = itemsQueryable?.Where(c => c.Total <= maxMedals); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(nameFilter)) |
|
|
|
|
|
|
|
result = result.Where(c => c.Name.Contains(nameFilter, StringComparison.CurrentCultureIgnoreCase)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (minMedals > 0) |
|
|
|
|
|
|
|
result = result.Where(c => c.Total >= minMedals); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|