Skip to content
Overview

Overview

Data lists for Blazor and .NET MAUI Blazor Hybrid: a table and a card grid with search, filters, sorting, paging, selection and bulk actions, for .NET developers who build list pages.

On this page

A list page needs search, filters, sort, paging and URL state wired to a data source, and it needs them again on the next page. KlyDataList holds that state, loads rows from memory, an IQueryable or any asynchronous provider, and shares it with parts you compose: table, grid, search field, filter tags, pagination. The state lives in the query string, so the same markup works in static server rendering (links and forms) and in the interactive render modes. The request and filter model comes from Klyroo.Query and the controls are Klyroo.UI components.

Prerequisites

To use the library in an app:

  • The .NET 11 SDK, and an app that targets net11.0. The packages are prereleases, so every dotnet add package command needs --prerelease.
  • A Blazor app for Klyroo.Table: a Blazor Web App or a .NET MAUI Blazor Hybrid app. Selection, the selection bar and actions need an interactive render mode (Interactive Server, WebAssembly or Auto); in static server rendering, sorting, filtering and paging work through links and GET forms. In a WebAssembly or Auto app, register the services in the server project and in the .Client project.
  • Klyroo.UI set up in the app. Klyroo.Table brings the Klyroo.UI package, and AddKlyrooTable() registers its services, but the layout still needs the Klyroo.UI stylesheets in <head> and <KlyApp> around the body, as described in the Klyroo.UI installation.
  • Klyroo.Query for the list state; Klyroo.Table brings it. To run lists against a database through EF Core, add Klyroo.Query.EntityFrameworkCore (EF Core 10.0.15 or later). To cut days in the user's time zone in static server rendering, add Klyroo.UI.Server and call AddKlyrooServer().
  • A browser with the native popover API, which Klyroo.UI uses: Chrome and Edge 114, Safari 17 or Firefox 125, or later. In a .NET MAUI app, that means iOS or Mac Catalyst 17, or an Android System WebView 114 or later.
  • Network access on the first build only if your app self-hosts web fonts (KlyrooFont), uses icons outside the built-in set, or compiles Tailwind (KlyrooTailwind): the build downloads them once and caches them under obj/klyroo. Node.js is not needed.
  • Klyroo.Table.Core alone (the tree model) runs in any .NET 11 app.

To build this repository you need the .NET 11 SDK (a newer SDK works too, see global.json) and clones of klyroo-query and klyroo-ui in the same parent folder: some projects reference them by relative path (../klyroo-query/...). See Contributing.

Installation

Shell
dotnet add package Klyroo.Table --prerelease

Register the services in Program.cs, in the server project and in the WebAssembly client project if you have one, or in MauiProgram.cs:

C#
using Klyroo.Table;

builder.Services.AddKlyrooTable();

Add the imports to _Imports.razor:

Razor
@using Klyroo.UI
@using Klyroo.Table
@using Klyroo.Query

Klyroo.Table ships no stylesheet that is safe to load next to the Klyroo.UI one, so the app compiles Tailwind CSS itself. See Getting started for the stylesheet setup.

For code that needs no UI, install only the core package:

Shell
dotnet add package Klyroo.Table.Core --prerelease

Quick start

Headless, with Klyroo.Table.Core: build the nodes of a tree of rows.

C#
using Klyroo.Query;
using Klyroo.Table;

Employee[] staff =
[
    new(1, "Ada", [new(2, "Grace", [new(3, "Alan")]), new(4, "Linus")]),
];

var schema = DataListSchema.For<Employee>(s => s.RowKey(e => e.Id));
var tree = new DataListTree<Employee> { Children = e => e.Reports, DefaultExpandedDepth = 2 };

var (roots, nodes) = tree.BuildTree(staff, schema);
foreach (var node in nodes)
{
    Console.WriteLine($"{new string(' ', node.Depth * 2)}{node.Item.Name}");
}

public sealed record Employee(int Id, string Name, IReadOnlyList<Employee>? Reports = null);

In a Blazor page, a searchable, sortable, paged table of in-memory rows:

Razor
@page "/customers"

<KlyDataList TItem="Customer" Schema="Schema" Items="Customers" Label="Customers" />

@code {
    private sealed record Customer(int Id, string Name, string Country, decimal Mrr);

    private static readonly DataListSchema<Customer> Schema = DataListSchema.For<Customer>(s => s
        .RowKey(c => c.Id)
        .Search(c => c.Name, c => c.Country)
        .Field(c => c.Name, f => f.Sortable())
        .Field(c => c.Country, f => f.Sortable())
        .Field(c => c.Mrr, f => f.Sortable()));

    private static readonly Customer[] Customers =
    [
        new(1, "Acme", "France", 1200m),
        new(2, "Globex", "Germany", 800m),
        new(3, "Initech", "France", 450m),
    ];
}

Without child content the list renders a default layout: a search field (when the schema has search fields), the result count, a refresh button, filter tags (when the schema has filters), a table with one column per schema field, and numbered pagination. Child content replaces that layout with the parts you place.

Documentation

Getting started Step-by-step first integration
Guides Task-oriented recipes
Concepts How the library works
Platforms Render modes, .NET MAUI, NativeAOT
API reference Every public type and member
FAQ Troubleshooting and limitations

Compatibility

  • .NET 11 SDK.
  • Blazor Web App in static server rendering, Interactive Server, WebAssembly or Auto. In static rendering the controls are links and GET forms; selection and actions need an interactive render.
  • .NET MAUI Blazor Hybrid: the package declares browser, ios, android, maccatalyst and windows as supported platforms. This repository has no MAUI app or test that runs it.
  • NativeAOT and trimming: Klyroo.Table.Core sets IsAotCompatible and IsTrimmable, and CI builds it with the AOT and trimming analyzers. Klyroo.Table sets IsTrimmable only.
  • Tailwind CSS v4 compiled by your app, as described in Getting started.

Contributing

Contributions are welcome. Read CONTRIBUTING.md before opening a pull request, and follow the code of conduct. Report security issues privately as described in SECURITY.md.

License

MIT