Skip to content
IzzyBlazor 0.1.0-alpha.20

Enter all results ↑ ↓ move Esc close

Aggregates

Since 0.1.0-alpha.20
Totals over every row the filters match, in the footer.

Static server-side rendering: no circuit, no WebAssembly.

Use Aggregate on a column for a sum, average, lowest, highest or count in the footer, or AggregateBy for your own, as an expression that runs in the database. It covers every row the filters match, not the page, and needs no grouping. With an ItemsProvider, add a GroupsProvider, which answers for the totals.

Preview

Orders with totals
OrderCustomer
Status
DateTotalPaid
1001Margaret HamiltonFailedSep 8$66.25No
1002Katherine JohnsonRefundedSep 15$108.00No
1003Grace HopperPendingSep 22$149.75No
1004Barbara LiskovPaidSep 29$191.50Yes
1005Linus TorvaldsFailedOct 6$233.25No
Count: 23Latest: Oct 20Sum: $6,106.5022%

Code

Aggregates.razor
@using Rows = IzzyBlazor.Site.Examples.Table.Orders
@using Status = IzzyBlazor.Site.Examples.Table.OrderStatus
@* The footer covers every order the filters match, not just this page. Filter by status and it follows.
   The last column's is your own: the share of orders paid, worked out in the database. *@
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders with totals" QueryPrefix="totals-" Grow>
    <PropertyColumn Property="o => o.Number" Title="Order" Align="CellAlign.Start" Width="7.Rem" Aggregate="DataAggregate.Count" />
    <PropertyColumn Property="o => o.Customer" Width="12.Rem" />
    <PropertyColumn Property="o => o.Status" Filterable />
    <PropertyColumn Property="o => o.Date" Format="MMM d" Aggregate="DataAggregate.Max" AggregateLabel="Latest" />
    <PropertyColumn Property="o => o.Total" Format="C" Width="9.Rem" Aggregate="DataAggregate.Sum" />
    <TemplateColumn Title="Paid" Width="6.Rem" Align="CellAlign.End" AggregateLabel="" AggregateFormat="P0"
                    AggregateBy="g => g.Any() ? (double)g.Count(o => o.Status == Status.Paid) / g.Count() : 0">
        @(context.Status == Status.Paid ? "Yes" : "No")
    </TemplateColumn>
</DataGrid>

Connection lost

Rejoining the server…