Soenneker.Blazor.DataTables
4.0.2914
Prefix Reserved
dotnet add package Soenneker.Blazor.DataTables --version 4.0.2914
NuGet\Install-Package Soenneker.Blazor.DataTables -Version 4.0.2914
<PackageReference Include="Soenneker.Blazor.DataTables" Version="4.0.2914" />
<PackageVersion Include="Soenneker.Blazor.DataTables" Version="4.0.2914" />
<PackageReference Include="Soenneker.Blazor.DataTables" />
paket add Soenneker.Blazor.DataTables --version 4.0.2914
#r "nuget: Soenneker.Blazor.DataTables, 4.0.2914"
#:package Soenneker.Blazor.DataTables@4.0.2914
#addin nuget:?package=Soenneker.Blazor.DataTables&version=4.0.2914
#tool nuget:?package=Soenneker.Blazor.DataTables&version=4.0.2914
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 | Versions 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. |
-
net10.0
- Soenneker.Asyncs.Initializers (>= 4.0.86)
- Soenneker.Blazor.Extensions.EventCallback (>= 4.0.458)
- Soenneker.Blazor.Utils.InteropEventListener (>= 4.0.4081)
- Soenneker.Blazor.Utils.ResourceLoader (>= 4.0.1724)
- Soenneker.DataTables.Dtos.Column (>= 4.0.26)
- Soenneker.DataTables.Dtos.ServerResponse (>= 4.0.21)
- Soenneker.DataTables.Dtos.ServerSideRequest (>= 4.0.27)
- Soenneker.Lepton.Suite (>= 4.0.59)
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.2914 | 0 | 8/30/2026 |
| 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 |
Update dependency Soenneker.Blazor.Utils.ResourceLoader to 4.0.1724 (#4282)