Skip to content

Commit

Permalink
#502 [doc] Cleanup demos in documentation by using IDemoDataService -…
Browse files Browse the repository at this point in the history
… HxCheckboxList
  • Loading branch information
hakenr committed Jan 14, 2024
1 parent d044b7a commit b434a54
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
@using System.Globalization
@inject IDemoDataService DemoDataService

<EditForm Model="@model">
<HxCheckboxList TItem="CultureInfo"
TValue="string"
Label="Cultures"
ItemTextSelector="@(item => item.EnglishName)"
ItemValueSelector="@(item => item.EnglishName)"
Data="@data"
@bind-Value="@model.CultureInfos" />
</EditForm>
<HxCheckboxList TItem="EmployeeDto"
TValue="int"
Label="Employees"
Data="@data"
ItemTextSelector="@(employee => employee.Name)"
ItemValueSelector="@(employee => employee.Id)"
@bind-Value="selectedEmployeeIds" />

<p>Selected values: @String.Join(", ", model.CultureInfos ?? Enumerable.Empty<string>())</p>
<p class="mt-2">
Selected employee IDs: @String.Join(", ", selectedEmployeeIds.Select(i => i.ToString()) ?? Enumerable.Empty<string>())
</p>

@code
{
private Model model = new Model();
private List<CultureInfo> data = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
.OrderBy(item => item.EnglishName)
.Take(10)
.OrderByDescending(i => i.ToString()) // sorting test
.ToList();
private IEnumerable<EmployeeDto> data;
private List<int> selectedEmployeeIds { get; set; } = new();

private class Model
{
public List<string> CultureInfos { get; set; }
}
protected override async Task OnParametersSetAsync()
{
data = await DemoDataService.GetPreferredEmployeesAsync(count: 5);
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
@using System.Globalization
@inject IDemoDataService DemoDataService

<EditForm Model="@model">
<HxCheckboxList TItem="CultureInfo"
TValue="string"
ItemTextSelector="@(item => item.EnglishName)"
ItemValueSelector="@(item => item.EnglishName)"
Data="@data"
@bind-Value="@model.CultureInfos"
Inline="true" />
</EditForm>

<p>Selected values: @String.Join(", ", model.CultureInfos ?? Enumerable.Empty<string>())</p>
<HxCheckboxList TItem="EmployeeDto"
TValue="int"
Data="@data"
ItemTextSelector="@(employee => employee.Name)"
ItemValueSelector="@(employee => employee.Id)"
@bind-Value="selectedEmployeeIds"
Inline="true" />

@code
{
private Model model = new Model();
private List<CultureInfo> data = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
.OrderBy(item => item.EnglishName)
.Take(10)
.OrderByDescending(i => i.ToString()) // sorting test
.ToList();
private IEnumerable<EmployeeDto> data;
private List<int> selectedEmployeeIds { get; set; } = new();

private class Model
{
public List<string> CultureInfos { get; set; }
}
protected override async Task OnParametersSetAsync()
{
data = await DemoDataService.GetPreferredEmployeesAsync(count: 5);
}
}

0 comments on commit b434a54

Please sign in to comment.