Enterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

Table Column

Used to display multiple pieces of data with similar structures, data can be sorted, filtered, compared or other custom operations.

Add column header display name by setting Text

Demo

The fields in the table component TableColumns template are automatically displayed according to the DisplayName tag value of the bound model. If you want to customize the display name, please set Text property

Loading...

Add the first column of the table by setting IsMultipleSelect=true to select the column

Demo
Loading...

By setting ShowCheckboxText=true the display text in the first column of the table is select

Demo
Loading...

RowTemplate internal component TableCell set Checkbox and set related data binding. In this example, data binding will select The box component is bound to the value

Demo
Loading...

By setting the TableColumn Width property, the column width is controlled, and the inline button operation column width is controlled by the ExtendButtonColumnWidth property

Demo

Continue the previous example in this example, implement four custom function buttons, and extend them to the row. When each button is clicked, there is a corresponding callback delegate method. TableToolbarButton uses It is the way of Delegate to complete the data exchange. When the toolbar button is clicked, set the OnClick delegate method to obtain the selected row data set in the table

Continue the previous example in this example, implement four custom function buttons, and extend them to the row. When each button is clicked, there is a corresponding callback delegate method. TableToolbarButton uses It is the way of Delegate to complete the data exchange. When the toolbar button is clicked, set the OnClick delegate method to obtain the selected row data set in the table

Control whether the button is displayed by setting the button IsShow parameter

Loading...

Customize the Template template of the TableColumn column to implement any UI

Demo

In this example, the column DateTime value is displayed in different colors depending on whether the Complete value is true

In this example, the column Complete is displayed as a Checkbox component according to the value of Complete

Template template comes with Context associated context, its value is of type TableColumnContext

  • Value is the data value of the currently bound column
  • Row is the data value of the row where the currently bound column is located
Loading...

Format the cell value by specifying the FormatString or Formatter callback delegate when the column is bound

Demo

In this example the column DateTime values ​​are formatted according to FormatString to yyyy-MM-dd year month day format

In this example the column Count value is formatted according to Formatter to 0.00 with two decimal places

Loading...

Set the alignment by specifying the Align attribute when the column is bound

Demo

In this example the column DateTime is set to center alignment Alignment.Center

In this example the column Count is set to right-align Alignment.Right

Loading...

Set whether to display at different widths by specifying the ShownWithBreakPoint attribute

Demo

ShownWithBreakPoint enumeration value:

  • None is displayed if not set
  • Small is displayed when the screen is greater than or equal to 576px
  • Medium is displayed when the screen is greater than or equal to 768px
  • Large is displayed when the screen is greater than or equal to 992px
  • ExtraLarge is displayed when the screen is greater than or equal to 1200px

In this example, the Count column is set to BreakPoint.Large, that is, the screen will only be displayed when it is larger than 992px

Note:

Because the Table component supports mobile adaptation by default, the card mode is used for small screens. In this example, the explicit setting uses RenderMode="TableRenderMode. Table" mode

Loading...

Set whether the column is displayed by specifying the ShowColumnList attribute

Demo

ShowColumnList The default value is false, and if it is explicitly specified as true, the corresponding column adjustment button will appear in the toolbar

TableColumn adds the Visiable property, its default value is true, this column will not be displayed when the display is set to false

In this example, the quantity column is not displayed by setting Visible, and it can be displayed through the column control button

Trigger the OnColumnVisibleChanged callback when switch the column state Show/Hide

Loading...

Set table columns to allow resizing by specifying AllowResizing

Demo

Column resizing can only be done when the screen is too small and the scroll bar appears

Loading...

By specifying Template set the last column to display as a custom button

Demo
Loading...

By specifying the AutoGenerateColumns property value as true, enable the function of automatically generating column information based on the binding model

Demo

In this example, by setting the value of AutoGenerateColumns to true, the automatic column generation function is enabled. All attributes of the bound model entity class are all generated by default. code>AutoGenerateColumnAttribute tag class for function settings, such as:

  • Ignore means ignore this property, i.e. not generate
  • Readonly means read only
  • For more attributes, see Source code
In this example the date column is formatted through the [AutoGenerateColumn(Order = 1, FormatString = "yyyy-MM-dd")] tag; Set the template column in the code to customize the Complete column and use the Switch component to render; through the [AutoGenerateColumn(Order = 10)] tag in the Order set the display order

Loading...

By specifying OnColumnCreating callback, make secondary data changes to the column collection

Demo
Loading...

Custom rendering of columns by showing template Template

Demo
Loading...
@page "/tables/column"
@inject IOptionsMonitor<WebsiteOptions> WebsiteOption

<h3>@ColumnLocalizer["Title"]</h3>

<h4>@ColumnLocalizer["H4"]</h4>

<DemoBlock Title="@ColumnLocalizer["ColumnTextTitle"]" Introduction="@ColumnLocalizer["ColumnTextIntro"]" Name="ColumnText">
    <p>@((MarkupString)ColumnLocalizer["ColumnTextDesc"].Value)</p>
    <Table TItem="Foo" Items="@Items.Take(3)">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Text="@ColumnLocalizer["CustomColText1"]" Width="180" />
            <TableColumn @bind-Field="@context.Name" Text="@ColumnLocalizer["CustomColText2"]" />
            <TableColumn @bind-Field="@context.Address" Text="@ColumnLocalizer["CustomColText3"]" />
            <TableColumn @bind-Field="@context.Complete" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["SelectTitle"]" Introduction="@ColumnLocalizer["SelectIntro"]" Name="Select">
    <Table TItem="Foo" Items="@Items.Take(3)" IsMultipleSelect="true">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Complete" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["ShowCheckboxTitle"]" Introduction="@ColumnLocalizer["ShowCheckboxIntro"]" Name="ShowCheckbox">
    <Table TItem="Foo" Items="@Items.Take(3)" IsMultipleSelect="true" ShowCheckboxText="true">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Complete" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["DisabledTitle"]" Introduction="@ColumnLocalizer["DisabledIntro"]" Name="Disabled">
    <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">
                <Template Context="value">
                    <Checkbox Value="@value.Value" IsDisabled="true"></Checkbox>
                </Template>
            </TableColumn>
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["WidthTitle"]" Introduction="@ColumnLocalizer["WidthIntro"]" Name="Width">
    <p>@((MarkupString)ColumnLocalizer["WidthP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["WidthP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["WidthP3"].Value)</p>
    <Table TItem="Foo" @ref="TableRows"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowSearch="false" IsMultipleSelect="true"
           ShowExtendButtons="true" ExtendButtonColumnWidth="240"
           OnQueryAsync="@OnQueryAsync">
        <TableToolbarTemplate>
            <TableToolbarButton TItem="Foo" Color="Color.Primary" Icon="fa fa-fw fa-edit" IsEnableWhenSelectedOneRow="true" Text="@ColumnLocalizer["WidthButtonText1"]" OnClickCallback="@CustomerButton" />
            <TableToolbarButton TItem="Foo" Color="Color.Success" Icon="fa fa-fw fa-edit" IsEnableWhenSelectedOneRow="true" Text="@ColumnLocalizer["WidthButtonText2"]" OnClickCallback="@CustomerButton" />
            <TableToolbarButton TItem="Foo" Color="Color.Warning" Icon="fa fa-fw fa-edit" IsEnableWhenSelectedOneRow="true" Text="@ColumnLocalizer["WidthButtonText3"]" OnClickCallback="@CustomerButton" />
            <TableToolbarButton TItem="Foo" Color="Color.Danger" Icon="fa fa-fw fa-edit" IsEnableWhenSelectedOneRow="true" Text="@ColumnLocalizer["WidthButtonText4"]" OnClickCallback="@CustomerButton" />
        </TableToolbarTemplate>
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
        </TableColumns>
        <RowButtonTemplate>
            <TableCellButton Color="Color.Primary" Icon="fa fa-edit" Text="@ColumnLocalizer["WidthButtonText1"]" OnClick="@(() => OnRowButtonClick(context, ColumnLocalizer["WidthButtonText1"]))" />
            <TableCellButton Color="Color.Success" Icon="fa fa-edit" Text="@ColumnLocalizer["WidthButtonText2"]" OnClick="@(() => OnRowButtonClick(context, ColumnLocalizer["WidthButtonText2"]))" />
            <TableCellButton Color="Color.Warning" Icon="fa fa-edit" Text="@ColumnLocalizer["WidthButtonText3"]" OnClick="@(() => OnRowButtonClick(context, ColumnLocalizer["WidthButtonText3"]))" />
            <TableCellButton Color="Color.Danger" Icon="fa fa-edit" Text="@ColumnLocalizer["WidthButtonText4"]" OnClick="@(() => OnRowButtonClick(context, ColumnLocalizer["WidthButtonText4"]))" />
            <TableCellPopconfirmButton Color="Color.Info" Icon="fa fa-edit" Text="" OnConfirm="@(() => OnRowButtonClick(context, ColumnLocalizer["WidthConfirmButtonText"]))" />
        </RowButtonTemplate>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["TableColumnTitle"]" Introduction="@ColumnLocalizer["TableColumnIntro"]" Name="TableColumn">
    <p>@((MarkupString)ColumnLocalizer["TableColumnP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["TableColumnP2"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["TableColumnP3"].Value)</p>
    <ul>
        <li>@((MarkupString)ColumnLocalizer["TableColumnli1"].Value)</li>
        <li>@((MarkupString)ColumnLocalizer["TableColumnli2"].Value)</li>
    </ul>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180">
                <Template Context="value">
                    @if (value.Row.Complete)
                    {
                        <div class="text-success">@value.Value</div>
                    }
                    else
                    {
                        <div class="text-danger">@value.Value</div>
                    }
                </Template>
            </TableColumn>
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Complete" Width="100">
                <Template Context="value">
                    <Checkbox Value="@value.Value" IsDisabled="true"></Checkbox>
                </Template>
            </TableColumn>
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["FormatterTitle"]" Introduction="@ColumnLocalizer["FormatterIntro"]" Name="Formatter">
    <p>@((MarkupString)ColumnLocalizer["FormatterP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["FormatterP2"].Value)</p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" Formatter="@IntFormatter" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["AlignTitle"]" Introduction="@ColumnLocalizer["AlignIntro"]" Name="Align">
    <p>@((MarkupString)ColumnLocalizer["AlignP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["AlignP2"].Value)</p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" Align="Alignment.Center" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" Formatter="@IntFormatter" Width="60" Align="Alignment.Right" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["ShownWithBreakPointTitle"]" Introduction="@ColumnLocalizer["ShownWithBreakPointIntro"]" Name="ShownWithBreakPoint">
    <p>@((MarkupString)ColumnLocalizer["ShownWithBreakPointP1"].Value)</p>
    <ul class="ul-demo mb-3">
        <li>@((MarkupString)ColumnLocalizer["ShownWithBreakPointLi1"].Value)</li>
        <li>@((MarkupString)ColumnLocalizer["ShownWithBreakPointLi2"].Value)</li>
        <li>@((MarkupString)ColumnLocalizer["ShownWithBreakPointLi3"].Value)</li>
        <li>@((MarkupString)ColumnLocalizer["ShownWithBreakPointLi4"].Value)</li>
        <li>@((MarkupString)ColumnLocalizer["ShownWithBreakPointLi5"].Value)</li>
    </ul>
    <p>@((MarkupString)ColumnLocalizer["ShownWithBreakPointP2"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["ShownWithBreakPointP3"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["ShownWithBreakPointP4"].Value)</p>
    <Table TItem="Foo" RenderMode="TableRenderMode.Table"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" Align="Alignment.Center" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" ShownWithBreakPoint="BreakPoint.Large" Formatter="@IntFormatter" Width="60" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["VisibleTitle"]" Introduction="@ColumnLocalizer["VisibleIntro"]" Name="Visible">
    <p>@((MarkupString)ColumnLocalizer["VisibleP1"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["VisibleP2"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["VisibleP3"].Value)</p>
    <p>@((MarkupString)ColumnLocalizer["VisibleP4"].Value)</p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowAddButton="false" ShowEditButton="false" ShowDeleteButton="false"
           ShowExtendButtons="false" ShowColumnList="true"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" Width="290" />
            <TableColumn @bind-Field="@context.Education" />
            <TableColumn @bind-Field="@context.Count" Visible="false" />
            <TableColumn @bind-Field="@context.Complete" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["AllowResizingTitle"]" Introduction="@ColumnLocalizer["AllowResizingIntro"]" Name="AllowResizing">
    <p>@((MarkupString)ColumnLocalizer["AllowResizingP1"].Value)</p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource" AllowResizing="true"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["TemplateTitle"]" Introduction="@ColumnLocalizer["TemplateIntro"]" Name="Template">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="120" FormatString="yyyy-MM-dd" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
            <TableColumn @bind-Field="@context.Id" Text="">
                <Template Context="v">
                    <PopConfirmButton Text="Test" Size="Size.ExtraSmall" />
                </Template>
            </TableColumn>
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["AutoGenerateColumnsTitle"]" Introduction="@ColumnLocalizer["AutoGenerateColumnsIntro"]" Name="AutoGenerateColumns">
    <p>
        @((MarkupString)ColumnLocalizer["AutoGenerateColumnsP1"].Value)
        <ul class="ul-demo mb-3">
            <li>@((MarkupString)ColumnLocalizer["AutoGenerateColumnsLi1"].Value)</li>
            <li>@((MarkupString)ColumnLocalizer["AutoGenerateColumnsLi2"].Value)</li>
            <li>@((MarkupString)string.Format(ColumnLocalizer["AutoGenerateColumnsLi3"].Value, WebsiteOption.CurrentValue.BootstrapBlazorLink))</li>
        </ul>
        @((MarkupString)ColumnLocalizer["AutoGenerateColumnsP2"].Value)
    </p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" AutoGenerateColumns="true"
           ShowToolbar="false" IsMultipleSelect="true" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["OnColumnCreatingTitle"]" Introduction="@ColumnLocalizer["OnColumnCreatingIntro"]" Name="OnColumnCreating">
    <Tips>
        <p>@((MarkupString)ColumnLocalizer["OnColumnCreatingP1"].Value)</p>
        <ol>
            <li>@ColumnLocalizer["OnColumnCreatingLi1"]</li>
            <li>@((MarkupString)ColumnLocalizer["OnColumnCreatingLi2"].Value)</li>
        </ol>
        <p>@((MarkupString)ColumnLocalizer["OnColumnCreatingP2"].Value)</p>
    </Tips>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" AutoGenerateColumns="true"
           ShowToolbar="true" IsMultipleSelect="true" ShowExtendButtons="true"
           ShowDefaultButtons="true" OnSaveAsync="@OnSaveAsync"
           OnQueryAsync="@OnQueryAsync" OnColumnCreating="@OnColumnCreating" ShowEditButton="true">
    </Table>
</DemoBlock>

<DemoBlock Title="@ColumnLocalizer["AdvanceTitle"]" Introduction="@ColumnLocalizer["AdvanceIntro"]" Name="Advance">
    <Table TItem="Foo" IsPagination="true" PageItemsSource="@PageItemsSource" RenderMode="TableRenderMode.Table"
           IsStriped="true" IsBordered="true" OnQueryAsync="OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.Name" Width="220">
                <Template Context="value">
                    <div class="d-flex">
                        <div>
                            <img src="@Foo.GetAvatarUrl(value.Row.Id)" class="bb-avatar" />
                        </div>
                        <div class="ps-2">
                            <div>@value.Value</div>
                            <div class="bb-sub">@value.Row.Address</div>
                        </div>
                    </div>
                </Template>
            </TableColumn>
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Education" Align="Alignment.Center" Width="80" />
            <TableColumn @bind-Field="@context.Count" Width="160">
                <Template Context="value">
                    <div class="w-100">
                        <div>@value.Value %</div>
                        <Progress Value="@value.Value" Color="@Foo.GetProgressColor(value.Value)"></Progress>
                    </div>
                </Template>
            </TableColumn>
            <TableColumn @bind-Field="@context.Complete" Align="Alignment.Center" Width="80" />
        </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 BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;

namespace BootstrapBlazor.Shared.Samples.Table;

/// <summary>
/// Table 组件列属性示例代码
/// </summary>
public partial class TablesColumn
{
    [NotNull]
    private List<Foo>? Items { get; set; }

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

    [Inject]
    [NotNull]
    private IStringLocalizer<TablesColumn>? ColumnLocalizer { get; set; }

    [Inject]
    [NotNull]
    private ToastService? ToastService { get; set; }

    private static IEnumerable<int> PageItemsSource => new int[] { 5, 10, 20 };

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        Items = Foo.GenerateFoo(Localizer);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="d"></param>
    /// <returns></returns>
    private static Task<string> IntFormatter(object? d)
    {
        var ret = "";
        if (d is TableColumnContext<Foo, object?> data && data.Value != null)
        {
            var val = (int)data.Value;
            ret = val.ToString("0.00");
        }
        return Task.FromResult(ret);
    }

    private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
    {
        IEnumerable<Foo> items = Items;

        // 过滤
        var isFiltered = false;
        if (options.Filters.Any())
        {
            items = items.Where(options.Filters.GetFilterFunc<Foo>());
            isFiltered = true;
        }

        // 排序
        var isSorted = false;
        if (!string.IsNullOrEmpty(options.SortName))
        {
            var invoker = Foo.GetNameSortFunc();
            items = invoker(items, options.SortName, options.SortOrder);
            isSorted = true;
        }

        // 设置记录总数
        var total = items.Count();

        // 内存分页
        items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();

        return Task.FromResult(new QueryData<Foo>()
        {
            Items = items,
            TotalCount = total,
            IsSorted = isSorted,
            IsFiltered = isFiltered,
            IsSearch = true
        });
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="items"></param>
    private async Task CustomerButton(IEnumerable<Foo> items)
    {
        var cate = ToastCategory.Information;
        var title = ColumnLocalizer["CustomerButtonTitle"];
        var content = ColumnLocalizer["CustomerButtonContent", items.Count()];
        await ToastService.Show(new ToastOption()
        {
            Category = cate,
            Title = title,
            Content = content
        });
    }

    [NotNull]
    private Table<Foo>? TableRows { get; set; }

    private async Task OnRowButtonClick(Foo item, string text)
    {
        var cate = ToastCategory.Success;
        var title = $"{text} {item.Name}";
        var content = ColumnLocalizer["OnRowButtonClickContent"];
        await ToastService.Show(new ToastOption()
        {
            Category = cate,
            Title = title,
            Content = content
        });

        await TableRows.QueryAsync();
    }

    private static Task<bool> OnSaveAsync(Foo foo, ItemChangedType changedType)
    {
        return Task.FromResult(true);
    }

    private static Task OnColumnCreating(List<ITableColumn> columns)
    {
        foreach (var item in columns)
        {
            if (item.GetFieldName() == nameof(Foo.Name))
            {
                item.Readonly = true;
            }
        }
        return Task.CompletedTask;
    }
}

B 站相关视频链接

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
Themes
Bootstrap
Motronic
Ant Design (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor 组件库 更新到 6.6.0

首先感谢您对本套组件的关注,本目前本套组件已经拥有超过 120 个组件,本组件是基于 Bootstrap 风格的 Blazor 企业级组件库,提供如布局、导航、表单、数据、通知、图标、语音等几大类通用组件,每一个组件都经过静心设计,具有模块化、响应式和优秀的性能。从更多实际场景出发,满足多种场景的需求,极大的减少开发者时间成本,大大缩短开发周期,大幅提高开发效率,并提供了一套 通用权限管理系统 示例工程。Bootstrap Blazor 产品是由一支专业的全职技术团队进行维护,高效的响应速度,多元化的解决方案,长期提供支持,并提供企业级支持。目前已在多家知名国企内部使用,项目最高在线 1200 人稳定运行。右侧为国内人数最多的中文 Blazor QQ 社区二维码,欢迎扫描加群。

组件更新到 6.6.0 更新日志 [传送门] 如果组件给您带来了方便,请您帮忙给项目点亮 Star github gitee

QQGroup
QQ 795206915