CleanCodeJN.GenericApis.DataGrid
1.2.0
dotnet add package CleanCodeJN.GenericApis.DataGrid --version 1.2.0
NuGet\Install-Package CleanCodeJN.GenericApis.DataGrid -Version 1.2.0
<PackageReference Include="CleanCodeJN.GenericApis.DataGrid" Version="1.2.0" />
<PackageVersion Include="CleanCodeJN.GenericApis.DataGrid" Version="1.2.0" />
<PackageReference Include="CleanCodeJN.GenericApis.DataGrid" />
paket add CleanCodeJN.GenericApis.DataGrid --version 1.2.0
#r "nuget: CleanCodeJN.GenericApis.DataGrid, 1.2.0"
#:package CleanCodeJN.GenericApis.DataGrid@1.2.0
#addin nuget:?package=CleanCodeJN.GenericApis.DataGrid&version=1.2.0
#tool nuget:?package=CleanCodeJN.GenericApis.DataGrid&version=1.2.0
CleanCodeJN.GenericApis.DataGrid
A generic, server-side MudBlazor table component for CleanCodeJN.GenericApis.
Drop <CCJNDataGrid> onto any Blazor page and point it at your GraphQL endpoint — columns, types, paging, sorting and search are all handled automatically.
Requirements
- The backend must use
CleanCodeJN.GenericApiswith HotChocolate's auto-wiring (UseProjection,UseFiltering,UseSorting) - MudBlazor must be configured in the host app (
wwwroot/index.html/App.razor)
Installation
dotnet add package CleanCodeJN.GenericApis.DataGrid
Setup
Register the services in Program.cs:
builder.Services.AddCleanCodeJNDataGrid();
This registers MudServices, the named HttpClient and GraphQLDataGridService in one call.
Add the MudBlazor layout components to your App.razor or MainLayout.razor if not already present:
<MudThemeProvider />
<MudPopoverProvider />
<MudDialogProvider />
<MudSnackbarProvider />
Usage
@using CleanCodeJN.GenericApis.DataGrid.Components
<CCJNDataGrid TDto="CustomerGetDto"
GraphQLEndpoint="https://your-api/graphql"
EntityName="customer"
Title="Customers" />
EntityName is the lowercase GraphQL query field name — matches typeof(TEntity).Name.ToLowerInvariant() as generated by AutoQueryTypeExtensions.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
GraphQLEndpoint |
string |
yes | — | Full URL of the GraphQL endpoint |
EntityName |
string |
yes | — | Lowercase GraphQL query field name (e.g. "customer") |
Title |
string |
no | "" |
Heading rendered above the table |
Searchable |
bool |
no | true |
Show the search text field |
Dense |
bool |
no | false |
Compact row height |
Striped |
bool |
no | true |
Alternating row colours |
Elevation |
int |
no | 2 |
MudPaper shadow elevation |
BearerToken |
string? |
no | null |
Forwarded as Authorization: Bearer … header |
ExcludedProperties |
HashSet<string> |
no | [] |
DTO property names to hide (e.g. navigation properties) |
PageSizeOptions |
int[] |
no | [10,25,50,100] |
Page-size choices in the pager footer |
ColumnHeaders |
Dictionary<string,string>? |
no | null |
Custom column headers — maps property name → display label |
Column auto-detection
Columns are discovered automatically from the DTO via reflection. Scalar types are included; complex objects and collections are skipped.
Supported types: string, bool, char, byte, short, int, long, float, double, decimal, DateTime, DateTimeOffset, DateOnly, TimeOnly, TimeSpan, Guid, and all enum types (including nullable variants).
Property names are converted to headers by inserting spaces before each capital letter (FirstName → First Name). Override any header via ColumnHeaders.
Search
The search field queries all scalar columns simultaneously via a single GraphQL where: { or: [...] } clause:
- String columns —
contains(case-insensitive, server-side) - Numeric / Guid / bool columns —
eq(only applied when the search term is parseable as that type)
Search fires 500 ms after the last keystroke (debounce). The clear button resets immediately.
Example with all options
<CCJNDataGrid TDto="InvoiceGetDto"
GraphQLEndpoint="@Endpoint"
EntityName="invoice"
Title="Invoices"
Searchable="true"
Dense="true"
Striped="false"
Elevation="4"
BearerToken="@_token"
ExcludedProperties="@(new HashSet<string> { "Customer", "InternalNotes" })"
PageSizeOptions="@(new[] { 5, 10, 25 })"
ColumnHeaders="@(new Dictionary<string, string>
{
["Id"] = "Invoice ID",
["CustomerId"] = "Customer",
["Amount"] = "Amount (€)",
})" />
Programmatic reload
Expose a reference to the component and call ReloadTable() from code:
<CCJNDataGrid @ref="_grid" TDto="CustomerGetDto" ... />
@code {
private CCJNDataGrid<CustomerGetDto> _grid = default!;
private async Task Refresh() => await _grid.ReloadTable();
}
License
MIT
| 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
- FluentValidation (>= 12.1.1)
- Microsoft.AspNetCore.Components.Web (>= 10.0.5)
- Microsoft.AspNetCore.Components.WebAssembly (>= 10.0.5)
- Microsoft.Extensions.Http (>= 10.0.5)
- MudBlazor (>= 9.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added Validation support for the MudBlazor DataGrid component, allowing you to easily integrate FluentValidation rules into your data grid
operations. This enhancement ensures that your data grid can provide immediate feedback on user input, improving the overall
user experience and data integrity when working with CleanCodeJN.GenericApis. Needs to use CleanCodeJN.GenericApis v6.2.6 or higher for the new FluentValidation extensions.