Totals and export
Since 0.1.0-alpha.24Totals and export
To show a row's total of the rows under it, such as a phase's hours, set RollUp on the column. The footer's Aggregate works as in a DataGrid, over every row the filters match.
Static
Preview
Code
@* A project estimate: each phase shows the hours of the tasks under it, the footer the whole
project's, and the export keeps the phases and tasks as an outline. *@
<TreeList Items="Estimate.All" ItemKey="w => w.Id.ToString()" ItemParentKey="w => w.ParentId?.ToString()"
ItemExpanded="w => w.ParentId is null" Caption="Estimate" QueryPrefix="estimate-"
ExportExcelHref="/examples/estimate.xlsx" ExportCsvHref="/examples/estimate.csv" Grow>
<Columns>
<PropertyColumn Property="w => w.Task" Filterable />
<PropertyColumn Property="w => w.Owner" Filterable Width="10.Rem" />
<PropertyColumn Property="w => w.Hours" RollUp="DataAggregate.Sum" Aggregate="DataAggregate.Sum" Width="8.Rem" />
</Columns>
</TreeList>A rolled-up row shows the sum, average, lowest, highest or count of the rows at the ends of its branch, the ones with nothing under them, so no value is counted twice. While filtering, it counts only the rows kept. It needs Items: with an ItemsProvider, give the rows their totals, and add a GroupsProvider for the footer.
The export keeps the tree: give the endpoint's DataExport.WriteExcelAsync or WriteCsvAsync a tree: DataExportTree<T>.Of(key, parent). Excel shows the levels as an outline, so the rows fold, and CSV indents the first column.
While filtering, the rows above a match come too. To write the rolled-up totals, add .RollUp("hours", DataAggregate.Sum) for each such column.