Soenneker.Blazor.DataTables 4.0.2535

Prefix Reserved
dotnet add package Soenneker.Blazor.DataTables --version 4.0.2535
                    
NuGet\Install-Package Soenneker.Blazor.DataTables -Version 4.0.2535
                    
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.2535" />
                    
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.2535" />
                    
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.2535
                    
#r "nuget: Soenneker.Blazor.DataTables, 4.0.2535"
                    
#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.2535
                    
#: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.2535
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.DataTables&version=4.0.2535
                    
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 Soenneker.Blazor.DataTables

A Blazor interop library for DataTables

This library simplifies the integration of DataTables into Blazor applications, providing access to options, events, etc. A demo project showcasing common usages is included.

Diligence was taken to align the Blazor API with JS. Refer to the DataTables documentation for details. This is a work-in-progress; contribution is welcomed.

Installation

dotnet add package Soenneker.Blazor.DataTables

Add the following to your Startup.cs file

public void ConfigureServices(IServiceCollection services)
{
    services.AddDataTablesInteropAsScoped();
}

Usage

@using Soenneker.Blazor.DataTables

<DataTable Options="_options">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>John Doe</td>
            <td>Developer</td>
            <td>London</td>
            <td>28</td>
            <td>2017/04/25</td>
            <td>$320,800</td>
        </tr>
    </tbody>
</DataTable>

@code{

    private readonly DataTableOptions _options_ = new()
    {
        Searching = true,
        LengthChange = false,
        Info = false,
        Paging = false,
        Order = [new object[] {0, "asc"}]
    };
}

Custom Processing Indicators

When using server-side processing, you can override the default DataTables processing indicator with custom Blazor content. This feature allows you to:

  • Display custom Blazor components as the processing indicator
  • Use any Blazor markup, components, and styling
  • Disable the processing indicator entirely

Basic Usage

<DataTable Options="tableOptions" OnServerSideRequest="HandleServerSideRequest">
    <ProcessingIndicator>
        <div class="text-center">
            <div class="spinner-border text-primary" role="status"></div>
            <div class="mt-2">Loading data from server...</div>
        </div>
    </ProcessingIndicator>
    <ChildContent>
        <thead>
            <tr>
                <th data-data="id">ID</th>
                <th data-data="name">Name</th>
                <th data-data="email">Email</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </ChildContent>
</DataTable>

Continuation Token Support

The DataTables component supports continuation token-based pagination, which is useful for services like Azure Table Storage, Cosmos DB, or other cloud storage solutions that use continuation tokens instead of traditional offset-based pagination.

How Continuation Tokens Work

The component automatically emulates traditional DataTables pagination behavior while using continuation tokens under the hood:

  1. First Request: No continuation token is sent
  2. Server Response: Server returns data along with a continuation token for the next page
  3. Subsequent Requests: The continuation token from the previous response is sent with the next request
  4. Last Page: When there are no more pages, the server returns null for the continuation token
  5. Pagination Display: DataTables shows traditional pagination controls (Previous/Next buttons, page numbers) that work seamlessly with continuation tokens

Basic Usage

<DataTable @ref="_dataTable"
           OnServerSideRequest="HandleServerSideRequest"
           Options="_tableOptions">
    <thead>
        <tr>
            <th data-data="id">ID</th>
            <th data-data="name">Name</th>
            <th data-data="email">Email</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</DataTable>

@code {
    private DataTable _dataTable = null!;
    private readonly DataTableOptions _tableOptions = new()
    {
        ServerSide = true,
        PageLength = 10
    };

    private async Task<DataTableServerResponse> HandleServerSideRequest(DataTableServerSideRequest request)
    {
        // The request.ContinuationToken will contain the token from the previous response
        // or null for the first request
        
        var result = await YourService.GetDataAsync(
            pageSize: request.Length,
            continuationToken: request.ContinuationToken,
            searchTerm: request.Search?.Value,
            orderBy: GetOrderByColumn(request.Order)
        );
        
        // Return the response with the continuation token for the next page
        // Note: The component automatically calculates appropriate TotalRecords and TotalFilteredRecords
        // to make DataTables think it's using traditional pagination
        return DataTableServerResponse.Success(
            draw: request.Draw,
            recordsTotal: result.TotalRecords,
            recordsFiltered: result.TotalFilteredRecords,
            data: result.Data,
            continuationToken: result.NextContinuationToken // null when no more pages
        );
    }
}

Controlling Continuation Tokens

You can programmatically control continuation tokens using the DataTable component methods:

// Reset pagination to start from the beginning
_dataTable.ResetContinuationToken();

// Set a specific continuation token for the next request
_dataTable.SetContinuationToken("your-custom-token");

Backward Navigation Support

The component automatically stores continuation tokens for visited pages, enabling backward navigation:

  1. Original Token Storage: When you navigate to a page, the component stores the original continuation token used to reach that page
  2. Consistent Backward Navigation: When you click "Previous" or navigate to a previous page, the component uses the same original token for that page
  3. Token Consistency: Navigating back to a page multiple times will always use the same continuation token that was originally used to reach that page
  4. Efficient Navigation: If a direct token isn't available for a requested page, the component finds the closest available token and uses it
  5. Seamless UX: Users can navigate forward and backward through pages just like with traditional pagination

This ensures that your server-side logic receives the same continuation tokens when users navigate back to previously visited pages, maintaining consistency with your data source.

Implementation Notes

  • Automatic Handling: The component automatically manages continuation tokens between requests
  • Pagination Emulation: The component automatically calculates appropriate TotalRecords and TotalFilteredRecords values to make DataTables think it's using traditional offset-based pagination
  • Virtual Page Tracking: The component maintains a virtual page state that maps to continuation tokens, allowing DataTables pagination controls to work seamlessly
  • Backward Navigation: The component stores continuation tokens for visited pages, enabling backward navigation to previous pages
  • Token Storage: Continuation tokens are stored for each visited page, allowing efficient navigation in both directions
  • Fingerprinting: The component uses request fingerprinting to detect when search/filter parameters change and automatically resets the continuation token
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.2535 0 3/4/2026
4.0.2534 0 3/4/2026
4.0.2533 0 3/4/2026
4.0.2532 0 3/4/2026
4.0.2531 0 3/4/2026
4.0.2530 0 3/4/2026
4.0.2529 0 3/4/2026
4.0.2527 23 3/4/2026
4.0.2526 34 3/4/2026
4.0.2525 31 3/3/2026
4.0.2524 65 2/28/2026
4.0.2523 54 2/28/2026
4.0.2522 57 2/28/2026
4.0.2521 55 2/28/2026
4.0.2520 55 2/28/2026
4.0.2519 58 2/27/2026
4.0.2518 54 2/27/2026
4.0.2517 62 2/27/2026
4.0.2516 55 2/27/2026
4.0.2515 54 2/27/2026
Loading failed