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

Table

It is used to display multiple pieces of data with similar structure, and the data can be sorted, filtered, compared or other custom operations.

Set ShowToolbar to show the toolbar component

Demo
Loading...

Set ShowSearch to show the query component

Demo

In this example, the View button is displayed by setting ShowCardView to switch the rendering mode of the Table component

Loading...

Set the TableToolbarTemplate template to add custom extension buttons

Demo

In this example, a classic application scenario is implemented

  • Click the download button to open the download thread in the background for data processing, disable download button
  • A progress bar is displayed in the foreground, and it is being packaged and exported. During this period, other transactions can be processed.
  • After the data processing is completed, close the foreground prompt pop-up window, restore download button

In this example, by setting the IsAsync property of the TableToolbarButton button to enable asynchronous operation mode, please note that OnClickCallback needs to be in the callback delegate Use true async operations otherwise no effect

Loading...

By setting the ShowAddButton ShowEditButton ShowDeleteButton attribute value to control whether the individual function button is displayed, when ShowDefaultButtons is set to When false, all buttons are not displayed

Demo
Loading...
@page "/tables/toolbar"
@inject ToastService ToastService

<h3>@Localizer["H1"]</h3>
<h4>@Localizer["H2"]</h4>

<DemoBlock Title="@Localizer["P1"]" Introduction="@Localizer["P2"]" Name="Toolbar">
    <Table TItem="Foo"
           IsBordered="true" IsPagination="true" PageItemsSource="@PageItemsSource"
           IsMultipleSelect="true" ShowToolbar="true" ShowDefaultButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["P3"]" Introduction="@Localizer["P4"]" Name="QueryTabel">
    <p>@((MarkupString)Localizer["P5"].Value)</p>
    <Table TItem="Foo"
           IsBordered="true" IsPagination="true" PageItemsSource="@PageItemsSource"
           ShowToolbar="true" ShowSearch="true" ShowCardView="true" ShowAdvancedSearch="false" ShowDefaultButtons="false"
           OnQueryAsync="@OnSearchQueryAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["P6"]" Introduction="@Localizer["P7"]" Name="CustomButton">
    <p>@((MarkupString)Localizer["P8"].Value)</p>
    <ul class="ul-demo mb-3">
        <li>@((MarkupString)Localizer["P9"].Value)</li>
        <li>@((MarkupString)Localizer["P10"].Value)</li>
        <li>@((MarkupString)Localizer["P11"].Value)</li>
    </ul>
    <p>@((MarkupString)Localizer["P12"].Value)</p>
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowDefaultButtons="false" ShowSearch="false" ShowExtendButtons="false"
           OnQueryAsync="@OnQueryAsync">
        <TableToolbarTemplate>
            <TableToolbarButton TItem="Foo" Color="Color.Primary" Icon="fa-fw fa-solid fa-floppy-disk" Text="@Localizer["P13"]" IsAsync OnClickCallback="@DownloadAsync" />
            <TableToolbarButton TItem="Foo" Color="Color.Success" Icon="fa-fw fa-solid fa-pen-to-square" Text="@Localizer["P14"]" IsAsync OnClickCallback="@DownloadAsync" />
        </TableToolbarTemplate>
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" />
            <TableColumn @bind-Field="@context.Address" />
        </TableColumns>
    </Table>
</DemoBlock>

<DemoBlock Title="@Localizer["P15"]" Introduction="@Localizer["P16"]" Name="CustomDispalyButton">
    <Table TItem="Foo"
           IsPagination="true" PageItemsSource="@PageItemsSource"
           IsStriped="true" IsBordered="true" IsMultipleSelect="true"
           ShowToolbar="true" ShowAddButton="false" ShowEditButton="false" ShowExtendButtons="true"
           OnQueryAsync="@OnQueryAsync" OnDeleteAsync="@OnDeleteAsync">
        <TableColumns>
            <TableColumn @bind-Field="@context.DateTime" Width="180" />
            <TableColumn @bind-Field="@context.Name" Width="100" />
            <TableColumn @bind-Field="@context.Address" />
            <TableColumn @bind-Field="@context.Count" />
        </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/

namespace BootstrapBlazor.Shared.Samples.Table;

/// <summary>
/// 
/// </summary>
public sealed partial class TablesToolbar
{
    [Inject]
    [NotNull]
    private IStringLocalizer<Foo>? LocalizerFoo { get; set; }

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

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

    [NotNull]
    private List<Foo>? Items { get; set; }

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

        Items = Foo.GenerateFoo(LocalizerFoo);
    }

    private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
    {
        // Set the total number of records
        var total = Items.Count;

        // memory paging
        var items = Items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();

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

    private Task<QueryData<Foo>> OnSearchQueryAsync(QueryPageOptions options)
    {
        var items = Items.AsEnumerable();
        if (!string.IsNullOrEmpty(options.SearchText))
        {
            // Fuzzy query against SearchText
            items = items.Where(i => (i.Address ?? "").Contains(options.SearchText)
                    || (i.Name ?? "").Contains(options.SearchText));
        }

        // Set the total number of records
        var total = items.Count();

        // memory paging
        items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();

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

    private Task<bool> OnDeleteAsync(IEnumerable<Foo> items)
    {
        items.ToList().ForEach(foo => Items.Remove(foo));
        return Task.FromResult(true);
    }

    private async Task DownloadAsync(IEnumerable<Foo> items)
    {
        // Construct pop-up window configuration information and perform pop-up window operations
        var cate = ToastCategory.Information;
        var title = "Custom download example";
        var content = "Please select the data first, then click the download button";
        if (items.Any())
        {
            cate = ToastCategory.Success;
            content = $"start packing selected {items.Count()} data, this window will be closed automatically after completion";
        }

        var option = new ToastOption()
        {
            Category = cate,
            Title = title,
            Content = content,
        };

        // 弹出 Toast
        await ToastService.Show(option);

        // If the download item is selected for package download operation
        if (items.Any())
        {
            // Disable automatic shutdown
            option.IsAutoHide = false;

            // Start a background process for data processing
            // Passing Option used to be used to close the popup after the asynchronous operation
            await MockDownLoadAsync();

            // Close the popup associated with the option
            option.Close();

            // A pop-up window informs that the download is complete
            await ToastService.Show(new ToastOption()
            {
                Category = ToastCategory.Success,
                Title = "Custom download example",
                Content = "data download complete",
            });
        }
    }

    private static async Task MockDownLoadAsync()
    {
        // It takes 5 seconds to simulate the package download data here
        await Task.Delay(5000);
    }
}

B station related video link

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
img
Themes
Bootstrap
Motronic
Ant Design (完善中)
DevUI (制作中)
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 Component library updated to 7.0.8-beta05

Bootstrap Blazor at present has more than 120 components. This component is based on Bootstrap Blazor An enterprise-level component library that provides several types of common components such as layout, navigation, form, data, notification, icon, voice, etc. Each component has been carefully designed with modularity, responsiveness and excellent performance. Starting from more practical scenarios, meeting the needs of various scenarios, greatly reducing the time cost of developers, greatly shortening the development cycle, greatly improving development efficiency, and providing a set of General Rights Management System Example project。Bootstrap Blazor Products are maintained by a professional full-time technical team, with efficient response speed, diversified solutions, long-term support, and enterprise-level support. At present, it has been used in many well-known state-owned enterprises, and the project is running stably with a maximum of 1200 people online. On the right is the QR code of the Chinese Blazor QQ community with the largest number of people in China, welcome to scan and join the group.

component updated to 6.6.0 Change log [portal] If the component brings you convenience, please help to light up the project Star github gitee

QQGroup
QQ 795206915