CleanCodeJN.GenericApis.DataGrid
1.1.0
See the version list below for details.
dotnet add package CleanCodeJN.GenericApis.DataGrid --version 1.1.0
NuGet\Install-Package CleanCodeJN.GenericApis.DataGrid -Version 1.1.0
<PackageReference Include="CleanCodeJN.GenericApis.DataGrid" Version="1.1.0" />
<PackageVersion Include="CleanCodeJN.GenericApis.DataGrid" Version="1.1.0" />
<PackageReference Include="CleanCodeJN.GenericApis.DataGrid" />
paket add CleanCodeJN.GenericApis.DataGrid --version 1.1.0
#r "nuget: CleanCodeJN.GenericApis.DataGrid, 1.1.0"
#:package CleanCodeJN.GenericApis.DataGrid@1.1.0
#addin nuget:?package=CleanCodeJN.GenericApis.DataGrid&version=1.1.0
#tool nuget:?package=CleanCodeJN.GenericApis.DataGrid&version=1.1.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
- 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 full CRUD support: Add, Edit and Delete via GraphQL mutations (createX / updateX / deleteX)
- Three separate type parameters: TDto (read), TPostDto (create), TPutDto (update)
- Auto-generated forms via reflection: MudTextField, MudNumericField, MudCheckBox, MudDatePicker, MudSelect for enums — per property type
- Id fields are rendered as read-only in auto-generated forms
- RenderFragment escape hatch: AddFormContent and EditFormContent for fully custom forms
- Reusable CCJNDataGridDialog with inline error display (dialog stays open on failure)
- DataGridMutationConventions: configurable mutation name prefixes (default: create / update / delete)
- ExcludedEditProperties: hide specific DTO properties from Add/Edit forms
- OnCustomAdd / OnCustomEdit / OnCustomDelete: override default GraphQL mutations with custom handlers
- Nested input objects (e.g. complex DTO properties) are serialized recursively in mutation input literals
- Fixed: decimal values now serialized with InvariantCulture (dot separator) for GraphQL compatibility
- Fixed: create mutation return selection uses __typename instead of id (PostDto has no Id field)
- All UI texts translated to English
- AddMudServices() is now called automatically inside AddCleanCodeJNDataGrid()