Aggregates
Since 0.1.0-alpha.20Totals over every row the filters match, in the footer.
Static server-side rendering: no circuit, no WebAssembly.
Footer totals
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
| Order | Customer | Status Filter Status
| Date | Total | Paid |
|---|---|---|---|---|---|
| 1001 | Margaret Hamilton | Failed | Sep 8 | $66.25 | No |
| 1002 | Katherine Johnson | Refunded | Sep 15 | $108.00 | No |
| 1003 | Grace Hopper | Pending | Sep 22 | $149.75 | No |
| 1004 | Barbara Liskov | Paid | Sep 29 | $191.50 | Yes |
| 1005 | Linus Torvalds | Failed | Oct 6 | $233.25 | No |
| Count: 23 | Latest: Oct 20 | Sum: $6,106.50 | 22% |
Code
Rows = IzzyBlazor.Site.Examples.Table.Orders
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>