Aggregates in Blazorise Datagrid with large dataset example

Viewed 443

does anyone have an example of the Blazorise DataGrid with DataGridAggregates (for a column total) when using the large data set approach?

No footer appears when I try:

<DataGrid TItem="CustomerOrderSummaryDto"
          Data="@PagedResults?.Results"
          ReadData="@OnReadDataAsync"
          TotalItems="@PagedResults?.TotalCount"
          AggregateData="@_counts"
>
    <ChildContent>

        <DataGridColumn TItem="CustomerOrderSummaryDto" Field="@nameof(CustomerOrderSummaryDto.Total)"
                        Caption="Total" />

        <DataGridColumn TItem="CustomerOrderSummaryDto" Field="@nameof(CustomerOrderSummaryDto.OrderRef)"
                        Caption="Order Ref" />

        <DataGridAggregates>
            <DataGridAggregate TItem="CustomerOrderSummaryDto"
                               Field="@nameof( CustomerOrderSummaryDto.Total)"
                               Aggregate="DataGridAggregateType.Sum" DisplayFormat="{0:C}" />

        </DataGridAggregates>

I set _counts to a dummy IList with one dummy entry. The sample documentation is not clear on this interaction.

1 Answers

It's because you placed both columns and DataGridAggregates inside of ChildContent. When using aggregates you must separate them into different render fragments.

Example

<DataGrid TItem="Employee">
    <DataGridAggregates>
        // aggregates
    </DataGridAggregates>
    <DataGridColumns>
        // columns
    </DataGridColumns>
</DataGrid>
Related