BlazorUI Demo

Data grid

This example exercises local filtering, multi-sort, paging, selection, status dots, coloured rows and expandable details.

Interactive local grid

The same request contract is used by server-backed grids.

Customer 1 Customer 1 Active$127.351 Sep 2026
Customer 2 Customer 2 Active$254.7024 Aug 2026
Customer 3 Customer 3 Pending$382.0516 Aug 2026
Customer 4 Customer 4 Active$509.408 Aug 2026
Customer 5 Customer 5 Blocked$636.7531 Jul 2026
Customer 6 Customer 6 Pending$764.1023 Jul 2026
Customer 7 Customer 7 Active$891.4515 Jul 2026
Customer 8 Customer 8 Active$1,018.807 Jul 2026
Customer 9 Customer 9 Pending$1,146.1529 Jun 2026
Customer 10 Customer 10 Blocked$1,273.5021 Jun 2026
42 results
View code
<BuiDataGrid @ref="grid" TItem="Customer" Items="customers" ItemKey="x => x.Id"
             Selection="DataGridSelectionMode.Multiple" @bind-SelectedItems="selected"
             @bind-Page="page" @bind-PageSize="pageSize" Striped Dense ExpandOnRowClick
             RowColor="x => x.Overdue ? Palette.Rose : null">
    <Columns>
        <BuiDataGridColumn TItem="Customer" TValue="string" Field="x => x.Name" Truncate />
        <BuiDataGridColumn TItem="Customer" TValue="CustomerStatus" Field="x => x.Status" CellColor="StatusColor" ColorMode="CellColorMode.Dot" />
        <BuiDataGridColumn TItem="Customer" TValue="decimal" Field="x => x.Balance" Format="FormatCurrency" />
        <BuiDataGridColumn TItem="Customer" TValue="DateTime" Field="x => x.Joined" Format="FormatDate" />
    </Columns>
    <ChildContent Context="customer"><BuiStack Gap="2" Class="demo-detail"><BuiText Typo="Typo.Subtitle2">@customer.Name</BuiText><BuiText Typo="Typo.Body2" Color="Colors.Secondary">Customer @customer.Id · @customer.Email</BuiText></BuiStack></ChildContent>
</BuiDataGrid>

@code {
    private BuiDataGrid<Customer>? grid;
    private int page = 1;
    private int pageSize = 10;
    private IReadOnlyCollection<Customer> selected = [];
    private readonly Customer[] customers = Enumerable.Range(1, 42).Select(index => new Customer(index, $"Customer {index}", $"customer{index}@@example.com", index % 3 == 0 ? CustomerStatus.Pending : index % 5 == 0 ? CustomerStatus.Blocked : CustomerStatus.Active, index * 127.35m, DateTime.Today.AddDays(-index * 8), index % 7 == 0)).ToArray();
    private static string FormatCurrency(decimal value) => value.ToString("C");
    private static string FormatDate(DateTime value) => value.ToString("d MMM yyyy");
    private static IColor StatusColor(Customer value) => value.Status switch { CustomerStatus.Active => Colors.Success, CustomerStatus.Pending => Colors.Warning, _ => Colors.Error };
    private enum CustomerStatus { Active, Pending, Blocked }
    private sealed record Customer(int Id, string Name, string Email, CustomerStatus Status, decimal Balance, DateTime Joined, bool Overdue);
}