
Table Lookup
Used to automatically convert foreign key columns to Text
display text
Auto-translate display text by setting Lookup
Demo
In this example, by setting the Lookup
value of the Complete
column to the value
DataSource = new List<SelectedItem>
{
new SelectedItem { Value = "true", Text = Pass },
new SelectedItem { Value = "false", Text = Failed }
};
The component automatically converts Complete
to a preset in the DataSource
collection
In this example, the ILookupService
service is used for unified processing, and the Lookup
data collection is obtained from the service by setting the LookupServiceKey
value
@page "/tables/lookup"
<h3>@LookupLocalizer["Title"]</h3>
<h4>@((MarkupString)LookupLocalizer["Desc"].Value)</h4>
<DemoBlock Title="@LookupLocalizer["LookupTitle"]" Introduction="@LookupLocalizer["LookupIntro"]" Name="Lookup">
<p>@((MarkupString)LookupLocalizer["LookupP1"].Value)</p>
<Pre>DataSource = new List<SelectedItem>
{
new SelectedItem { Value = "true", Text = @Localizer["True"].Value },
new SelectedItem { Value = "false", Text = @Localizer["False"].Value }
};
</Pre>
<p>@((MarkupString)LookupLocalizer["LookupP2"].Value)</p>
<p>@((MarkupString)LookupLocalizer["LookupP3"].Value)</p>
@if (Items != null)
{
<Table TItem="Foo" Items="@Items.Take(3)">
<TableColumns>
<TableColumn @bind-Field="@context.DateTime" Width="180" />
<TableColumn @bind-Field="@context.Name" />
<TableColumn @bind-Field="@context.Complete" LookupServiceKey="Foo.Complete" />
</TableColumns>
</Table>
}
</DemoBlock>
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
namespace BootstrapBlazor.Shared.Samples.Table;
/// <summary>
///
/// </summary>
public partial class TablesLookup
{
[NotNull]
private List<Foo>? Items { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<Foo>? Localizer { get; set; }
[Inject]
[NotNull]
private IStringLocalizer<TablesLookup>? LookupLocalizer { get; set; }
/// <summary>
/// OnInitialized 方法
/// </summary>
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
await Task.Delay(200);
Items = Foo.GenerateFoo(Localizer);
}
}