Skip to content

DashboardTable

A sortable table of rows of your own type (KlyDashboardTable<TRow>) and a ranked list (KlyDashboardList) with a value, a percentage and a change per row.

On this page

Examples

Sortable table

Each column reads its value from the row with a delegate (DashboardTableColumn.For), so a wrong type does not compile. The kind of a column is Text, Number, Delta, Percent or Bar, and defaults to Number for a number type and Text otherwise. A header click cycles the sort, a numeric column going descending first, and Sort is bound with @bind-Sort. Sorting runs in the component on the rows you pass, so sort and page large results on the server. Limit is applied after sorting, and OnRowClick makes the first cell of each row a button as well as the row clickable. Statically rendered the headers do not sort.

Top customers

Click a header to sort, a row to pick it

EMEA
42.3K
310+12.5%
Americas
36.4K
268-4%
EMEA
28.9K
201+8.3%
Americas
24.1K
190+1.2%
APAC
19.6K
143+21.7%
APAC
15.2K
120-9.8%

Sort: revenue descending · Picked: nobody

Razor
<div class="flex w-full flex-col gap-3">
    <KlyDashboardGrid>
        <KlyDashboardTable TRow="Customer" Title="Top customers" Subtitle="Click a header to sort, a row to pick it" Rows="_rows" Columns="_columns"
                           @bind-Sort="_sort" Limit="6" OnRowClick="Pick" />
    </KlyDashboardGrid>
    <p class="m-0 text-sm text-(--klyroo-text-muted)">
        Sort: @(_sort is null ? "none" : $"{_sort.Key}{(_sort.Descending ? " descending" : " ascending")}") · Picked: @(_picked ?? "nobody")
    </p>
</div>

@code {
    private sealed record Customer(string Name, string Region, double Revenue, int Orders, double Growth);

    private DashboardTableSort? _sort = new("revenue", true);
    private string? _picked;

    private static readonly IReadOnlyList<DashboardTableColumn<Customer>> _columns =
    [
        DashboardTableColumn.For<Customer, string>("name", "Customer", r => r.Name),
        DashboardTableColumn.For<Customer, string>("region", "Region", r => r.Region),
        DashboardTableColumn.For<Customer, double>("revenue", "Revenue", r => r.Revenue, DashboardFormatPreset.Compact, kind: DashboardTableColumnKind.Bar),
        DashboardTableColumn.For<Customer, int>("orders", "Orders", r => r.Orders, DashboardFormatPreset.Integer),
        DashboardTableColumn.For<Customer, double>("growth", "Growth", r => r.Growth, kind: DashboardTableColumnKind.Delta),
    ];

    private static readonly IReadOnlyList<Customer> _rows =
    [
        new("Northwind", "EMEA", 42_300, 310, 12.5), new("Contoso", "Americas", 36_400, 268, -4.0), new("Lumeco", "EMEA", 28_900, 201, 8.3),
        new("Globex", "Americas", 24_100, 190, 1.2), new("Umbrella", "APAC", 19_600, 143, 21.7), new("Hooli", "APAC", 15_200, 120, -9.8),
        new("Initech", "Americas", 11_400, 88, 3.4), new("Fabrikam", "EMEA", 8_700, 61, 0.0),
    ];

    private void Pick(Customer row) => _picked = row.Name;
}

Ranked list

Each DashboardListItem has a label, a description, a value formatted with Format, a Percent, a Delta (green at zero or above, red below) and LeadingText in a circle. With OnRowClick the label of every row without an Href is a button, and Selected marks a row, which the page keeps.

Top products

Pick a row

1
Lighting
34%+12.5%18.4K
2
Furniture
29%-3.2%15.9K
3
Accessories
17%0%9.3K
4
Accessories
8%4.1K

Picked: nothing

Razor
<div class="flex w-full flex-col gap-3">
    <KlyDashboardGrid>
        <KlyDashboardList Title="Top products" Subtitle="Pick a row" Span="12" Items="Items()" Format="DashboardFormatPreset.Compact" OnRowClick="Pick" />
    </KlyDashboardGrid>
    <p class="m-0 text-sm text-(--klyroo-text-muted)">Picked: @(_picked ?? "nothing")</p>
</div>

@code {
    private static readonly IReadOnlyList<DashboardListItem> _items =
    [
        new("Desk lamp", "Lighting", Value: 18_400, Percent: 34, Delta: 12.5, LeadingText: "1"),
        new("Standing desk", "Furniture", Value: 15_900, Percent: 29, Delta: -3.2, LeadingText: "2"),
        new("Monitor arm", "Accessories", Value: 9_300, Percent: 17, Delta: 0, LeadingText: "3"),
        new("Cable tray", "Accessories", Value: 4_100, Percent: 8, LeadingText: "4"),
    ];

    private string? _picked;

    private IReadOnlyList<DashboardListItem> Items() => [.. _items.Select(i => i with { Selected = i.Label == _picked })];

    private void Pick(DashboardListItem item) => _picked = item.Label;
}

API

KlyDashboardTable<TRow>

A table over rows of your own type, with typed columns (text, number, delta, percent, bar) and click-to-sort headers.

Parameters

Name Type Default Description
Card bool true Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true .
Class string Classes added to the root element, merged last so they win over the theme.
Columns IReadOnlyList<DashboardTableColumn<TRow>> The column definitions, in display order.
Freshness bool? Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid.
Limit int? The maximum number of rows shown, applied after sorting. The CSV export holds the same rows.
Menu bool? Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid.
Rows IReadOnlyList<TRow> The rows. Each column reads its value from the row with its own delegate ( Boolean) ), and a null value shows the missing-value placeholder. Blazor infers TRow from this list or from Columns .
Sort (@bind-Sort) DashboardTableSort The active sort. The table updates it itself when a header is clicked, and SortChanged reports the change. Numeric columns sort descending first, then ascending, then unsorted. Empty cells always come last.
Source IDashboardSource The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately.
Span int 12 Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 12.
Subtitle string A secondary line under the title.
Title string The heading of the block.

Events

Name Type Description
OnRowClick EventCallback<TRow> Called with the row (the item of Rows ) when the user picks it. The first cell of each row is then a button, so the choice works with the keyboard and with a screen reader, and a click anywhere on the row does the same for the pointer. Use it to drill down, for example by setting a filter of the DashboardController .

KlyDashboardList

A ranked list of rows with an optional value, percentage and delta.

Parameters

Name Type Default Description
Card bool true Whether the block draws its own surface (border, background and shadow; only the background in a panels grid). Defaults to true .
Class string Classes added to the root element, merged last so they win over the theme.
Format DashboardFormatPreset DashboardFormatPreset.Number How the row values are formatted. Values: Number, Integer, Decimal, Compact, Percent, Ratio, Delta, Points, Signed.
Freshness bool? Shows an Updated footer built from Source.UpdatedAt . When null , the value of the enclosing KlyDashboardGrid.Freshness applies, or false outside a grid.
Items IReadOnlyList<DashboardListItem> The rows, in display order.
Limit int? The maximum number of rows shown. The table view and the CSV export hold the same rows.
Menu bool? Shows the View as table, Download CSV and Expand buttons in the header once the content is displayed. Download CSV saves the block's table as a CSV file named after the title. When null , the value of the enclosing KlyDashboardGrid.Menu applies, or false outside a grid.
Source IDashboardSource The resource whose state drives the block: a skeleton while it loads, an error message with a retry button, then the content. The block does not read Data from it, so pass the data through the other parameters. Without a source the content renders immediately.
Span int 6 Width of the block in columns of the grid, clamped between 1 and the Columns of the enclosing KlyDashboardGrid (12 outside a grid). Defaults to 6.
Subtitle string A secondary line under the title.
Title string The heading of the block.

Events

Name Type Description
OnRowClick EventCallback<DashboardListItem> Called with the row when the user picks it. The label of each row without an Href is then a button, so the choice works with the keyboard and with a screen reader, aria-pressed follows Selected , and a click anywhere on the row does the same for the pointer. A row with an Href keeps its link and does not raise this event. Use it to drill down, for example by setting a filter of the DashboardController .