Enterprise-level component library based on Bootstrap and Blazor

star nuget master download license repo commit

Table 表格

用于自动将外键列转换成 Text 显示文字

Lookup 外置数据源

通过设置 Lookup 自动翻译显示文字

Demo

本例中通过设置 CompleteLookup 值为

DataSource = new List<SelectedItem>
{
    new SelectedItem{ Value = "true", Text = Localizer["True"].Value },
    new SelectedItem{ Value = "false", Text = Localizer["False"].Value }
};

组件自动将 Complete 转换为 DataSource 集合中的预设值

Loading...
@page "/tables/lookup"

<h3>Table 表格</h3>

<h4>用于自动将外键列转换成 <code>Text</code> 显示文字</h4>

<Block Title="Lookup 外置数据源" Introduction="通过设置 <code>Lookup</code> 自动翻译显示文字">
    <p>本例中通过设置 <code>Complete</code> 列 <code>Lookup</code> 值为</p>
    <Pre>DataSource = new List&lt;SelectedItem&gt;
{
    new SelectedItem{ Value = "true", Text = Localizer["True"].Value },
    new SelectedItem{ Value = "false", Text = Localizer["False"].Value }
};
</Pre>
    <p>组件自动将 <code>Complete</code> 转换为 <code>DataSource</code> 集合中的预设值</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" Lookup="@DataSource" />
            </TableColumns>
        </Table>
    }
</Block>
// 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 BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Pages.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace BootstrapBlazor.Shared.Pages.Table
{
    /// <summary>
    /// 
    /// </summary>
    public partial class TablesLookup
    {
        [NotNull]
        private List<Foo>? Items { get; set; }

        [NotNull]
        private List<SelectedItem>? DataSource { get; set; }

        [Inject]
        [NotNull]
        private IStringLocalizer<Foo>? Localizer { get; set; }

        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            await Task.Delay(200);

            Items = Foo.GenerateFoo(Localizer);

            DataSource = new List<SelectedItem>
            {
                new SelectedItem{ Value = "true", Text = Localizer["True"].Value },
                new SelectedItem{ Value = "false", Text = Localizer["False"].Value }
            };
        }
    }
}

B 站相关视频链接

暂无

交流群

QQ群:BootstrapAdmin & Blazor 795206915(满) 675147445 欢迎加群讨论
Themes
Bootstrap
Ant Design (完善中)
Bluma (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload