Soenneker.Blazor.DataTables 4.0.2913

Prefix Reserved
dotnet add package Soenneker.Blazor.DataTables --version 4.0.2913
                    
NuGet\Install-Package Soenneker.Blazor.DataTables -Version 4.0.2913
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Blazor.DataTables" Version="4.0.2913" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.DataTables" Version="4.0.2913" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.DataTables" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Blazor.DataTables --version 4.0.2913
                    
#r "nuget: Soenneker.Blazor.DataTables, 4.0.2913"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Blazor.DataTables@4.0.2913
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Blazor.DataTables&version=4.0.2913
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.DataTables&version=4.0.2913
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Blazor.DataTables

A Blazor component and JavaScript interop layer for DataTables, including client-rendered rows, server-side callbacks, custom processing UI, and optional continuation-token paging.

Installation

dotnet add package Soenneker.Blazor.DataTables

The host application must load DataTables and its chosen styling integration before the component renders. This package does not bundle them. For example:

<link rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/datatables.net-bs5@3.0.0/css/dataTables.bootstrap5.min.css">
<script src="https://cdn.jsdelivr.net/npm/datatables.net@3.0.0/js/dataTables.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/datatables.net-bs5@3.0.0/js/dataTables.bootstrap5.min.js"></script>

DataTables 3 does not require jQuery. Load compatible major versions for optional DataTables extensions. In production, self-host these assets or apply appropriate integrity and Content Security Policy controls.

Register the scoped interop services:

using Soenneker.Blazor.DataTables.Registrars;

builder.Services.AddDataTablesInteropAsScoped();

Client-rendered rows

@using Soenneker.Blazor.DataTables
@using Soenneker.Blazor.DataTables.Options

<DataTable @ref="_table" Options="_options" class="table table-striped">
    <thead>
        <tr>
            <th>Name</th>
            <th>Office</th>
        </tr>
    </thead>
    <tbody>
        @foreach (Employee employee in _employees)
        {
            <tr @key="employee.Id">
                <td>@employee.Name</td>
                <td>@employee.Office</td>
            </tr>
        }
    </tbody>
</DataTable>

@code {
    private DataTable? _table;
    private readonly List<Employee> _employees = [];

    private readonly DataTableOptions _options = new()
    {
        Searching = true,
        PageLength = 25,
        Order = [new object[] { 0, "asc" }]
    };

    private async Task AddEmployee(Employee employee)
    {
        await _table!.RefreshWithDomUpdate(() => _employees.Add(employee));
    }
}

DataTables owns and rearranges the table DOM after initialization. Use RefreshWithDomUpdate when row content changes but the table structure and options stay the same. Use RecreateWithDomUpdate when columns or initialization options change; it destroys and rebuilds the JavaScript instance.

Offset-based server-side data

Leave UseContinuationTokenPaging disabled for a normal offset/limit backend:

<DataTable Options="_serverOptions"
           OnServerSideRequest="LoadPage">
    <thead>
        <tr>
            <th data-data="id">ID</th>
            <th data-data="name">Name</th>
            <th data-data="createdAt">Created</th>
        </tr>
    </thead>
    <tbody></tbody>
</DataTable>

@code {
    private readonly DataTableOptions _serverOptions = new()
    {
        ServerSide = true,
        Processing = true,
        PageLength = 25
    };

    private async Task<DataTableServerResponse> LoadPage(
        DataTableServerSideRequest request)
    {
        string orderBy = request.Order?.FirstOrDefault()?.Column switch
        {
            0 => "id",
            1 => "name",
            2 => "created_at",
            _ => "id"
        };

        PageResult<RowDto> page = await repository.LoadPage(
            offset: request.Start,
            limit: request.Length,
            search: request.Search?.Value,
            orderBy: orderBy);

        return DataTableServerResponse.Success(
            draw: request.Draw,
            recordsTotal: page.Total,
            recordsFiltered: page.FilteredTotal,
            data: page.Items);
    }
}

Always return request.Draw; DataTables uses it to discard out-of-order responses. Treat column indices, direction values, search text, and page sizes as untrusted input. Map order columns through an allowlist, cap page/search sizes, and use parameterized queries—never concatenate request values into SQL. Encode untrusted cell content or configure a text renderer instead of returning executable HTML.

Continuation-token paging

Enable the adapter explicitly for a backend that returns opaque next-page tokens:

private readonly DataTableOptions _options = new()
{
    ServerSide = true,
    UseContinuationTokenPaging = true,
    PagingType = "simple",
    PageLength = 25
};

private async Task<DataTableServerResponse> LoadTokenPage(
    DataTableServerSideRequest request)
{
    TokenPage<RowDto> page = await repository.LoadNext(
        request.ContinuationToken,
        request.Length,
        request.Search?.Value);

    return DataTableServerResponse.Success(
        draw: request.Draw,
        recordsTotal: page.Total ?? 0,
        recordsFiltered: page.FilteredTotal ?? 0,
        data: page.Items,
        continuationToken: page.NextToken);
}

Use a previous/next pager such as PagingType = "simple": an opaque token cannot jump directly to an unvisited page. Tokens for visited pages are retained for backward navigation. Search, ordering, column filters, or page-length changes reset token state. Call ResetContinuationToken() after external filters or the underlying dataset changes; SetContinuationToken(token) overrides the token used for the next request.

When the backend supplies positive total counts, they are preserved. Otherwise the adapter estimates counts so DataTables can keep paging until a response has no next token.

Custom processing content

Provide ProcessingIndicator to replace DataTables' processing element during server-side requests:

<DataTable Options="_serverOptions" OnServerSideRequest="LoadPage">
    <ProcessingIndicator>
        <div role="status">Loading…</div>
    </ProcessingIndicator>
    <ChildContent>
        
    </ChildContent>
</DataTable>

OnInitialize fires after DataTables reports initialization. OnDestroy fires during component disposal. The component destroys its JavaScript table, mutation observer, and .NET callback reference when removed.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2913 0 8/30/2026
4.0.2910 0 8/30/2026
4.0.2908 0 8/30/2026
4.0.2904 21 8/30/2026
4.0.2901 29 8/30/2026
4.0.2900 26 8/30/2026
4.0.2898 39 8/29/2026
4.0.2893 42 8/29/2026
4.0.2892 65 8/26/2026
4.0.2891 62 8/26/2026
4.0.2890 55 8/26/2026
4.0.2889 72 8/26/2026
4.0.2888 70 8/26/2026
4.0.2887 67 8/25/2026
4.0.2885 91 8/22/2026
4.0.2884 84 8/22/2026
4.0.2883 130 8/21/2026
4.0.2882 95 8/21/2026
4.0.2881 126 8/19/2026
4.0.2880 88 8/19/2026
Loading failed

Update dependency Soenneker.Asyncs.Initializers to 4.0.86 (#4275)