Grouping
Since 0.1.0-alpha.20
The members for grouping, and the types they use. Every member of
IzzyBlazor.DataGrid<TItem> is on the DataGrid API.
Properties (9)
Groupablebool = falseLets people group by columns, from a header's menu. Grouped, the grid's pages count top-level groups, so a group is never split, and each group's count and aggregates are the whole group's. With an ItemsProvider, it needs a GroupsProvider.
@bind-Groupstring?The grouping, outermost first, such as "status,-customer" (- for descending); null for InitialGroup. Works without Groupable, for a grouping people can't change. Binding it (@bind-Group) on an interactive page keeps it in the component instead of the URL.
InitialGroupstring?The grouping when the URL has none, such as "status".
GroupsOpenbool = falseWhether groups start open. They start closed by default, which is what a page of groups is for.
@bind-OpenGroupsIReadOnlyList<string>?Which groups are open, each by its values joined with /, escaped, such as "Shipped/Acme"; "*" is all of them, and "!Shipped" an exception to that. Binding it on an interactive page keeps it in the component.
GroupRowLimitint = 100The most rows drawn in one open group. Past it, the group says how many it has and links to showing only that group, with the grid's pages. Defaults to 100.
GroupPanelbool = falseKeeps the bar of what's grouped above the grid while nothing is, saying a header can be dragged there. Without it the bar shows only while grouped, and the first grouping is from a header's menu. Dragging needs script and a mouse or pen; the menu works everywhere.
Without JavaScript: With JavaScript off, the bar shows what's grouped, and headers can't be dragged to it.
ShowGroupedColumnsbool = falseKeeps a grouped column in the table. By default it leaves, as each group's row says its value.
GroupsProviderFunc<DataGroupRequest<TItem>, ValueTask<DataGroupResult>>?Counts and aggregates for an ItemsProvider, which a column's Aggregate needs. It gets one request for each level of groups, and one with no keys for the grand total. Answer it from a query with request.ToResultAsync. With Items, the grid works these out itself.
Parts (1)
Components written inside DataGrid, and the columns' members, which PropertyColumn and TemplateColumn share.
PropertyColumn<TItem, TValue>
A column that shows one property of each item, formatted, and can sort by it. The title and sort key come from the property ([Display(Name)] is used when present).
Groupablebool = trueIn a grid that groups, whether this column can be grouped by. Defaults to true, for a column with one value to compare.
GroupByExpression<Func<TItem, object?>>?What to group by, when it isn't the column's value: for a TemplateColumn<T>, or a coarser key such as o => o.Placed.Year. It runs in the database, so keep it to what yours can translate. "Show only this group" isn't offered, as no filter on the column can say it.
GroupFormatstring? (computed)A .NET format string for a group's value. Defaults to the column's own when it has no GroupBy.
GroupTemplateRenderFragment<DataGridGroup>?A group's label, in place of the column's title and the value. The count stays beside it.
Types (3)
DataGridGroup
recordA group, for a column's GroupTemplate.
| Member | Description |
|---|---|
Value object? | Its value, or null for none. |
Text string | Its value as the column shows it. |
Group DataGroup | Its count and aggregates, for the whole group. |
Level int | Its level, from 0. |
IsOpen bool | Whether it's open. |
DataGroupRequest
recordWhat a DataGrid asks its GroupsProvider for: one level of groups with their counts and aggregates, or, with no Keys, the one group of everything that matches, which is the grand total. Rows aren't part of it: an open group's rows come from the ItemsProvider, with the group's values in its filter. Answer it with ToResultAsync.
| Member | Description |
|---|---|
Keys IReadOnlyList<SortField> | The fields to group by, outermost first, and the order of each; empty for the grand total. |
Aggregates IReadOnlyList<DataAggregateField> | What to work out for each group, besides its count. |
Filter Filter? | The filter, or null for none. |
Search string? | Free text to look for, in the searchable fields; null for none. |
Skip int = 0 | Groups to skip. |
Take int? | Groups to take; null for every group. |
NeedsTotal bool = false | Whether the component needs how many groups there are in all. |
CancellationToken CancellationToken = CancellationToken.None | Canceled when the component no longer needs this answer. |
ToQueryString() | The request as a query string, for a GET API: |
ToResult(IQueryable<TItem> source) | The groups, from an in-memory list or a synchronous query, with the component's fields. |
ToResult(IQueryable<TItem> source, IReadOnlyList<DataField<TItem>> fields) | The groups, through these fields only, for a request that came over the wire: a key that isn't |
ToResultAsync(IQueryable<TItem> source, Func<IQueryable<object?[]>, CancellationToken, Task<int>> count, Func<IQueryable<object?[]>, CancellationToken, Task<List<object?[]>>> list) | The groups through your async methods, so Core needs no EF Core: |
ToResultAsync(IQueryable<TItem> source, IReadOnlyList<DataField<TItem>> fields, Func<IQueryable<object?[]>, CancellationToken, Task<int>> count, Func<IQueryable<object?[]>, CancellationToken, Task<List<object?[]>>> list) | The groups through your async methods, through these fields only. |
DataGroupResult
recordWhat a GroupsProvider returns.
| Member | Description |
|---|---|
Groups IReadOnlyList<DataGroup> | The groups, in order. For a grand total, one. |
Total int? | How many groups there are in all, when the request's |