Grand Total Row
A grand total row aggregates values across all rows in the grid and is displayed as an extra row at the top or bottom.
To enable it, set grandTotalRow(true) on the QueryBuilder. Without this flag the adapter will not compute the grand total even if the frontend requests it.
QueryBuilder<Entity, Long, Void> queryBuilder = QueryBuilder.builder(Entity.class, Entity_.id, entityManager)
.colDefs(...)
.grandTotalRow(true)
.build();
Providing Grand Total Data
The grand total row data is returned on loadSuccessParams.grandTotalData as part of the standard getRows response. The adapter only computes it when the request carries needsGrandTotal=true, so make sure to include it in the request body:
body: JSON.stringify({ ...params.request, needsGrandTotal: params.needsGrandTotal })
When needsGrandTotal is false the adapter sets grandTotalData to null. AG Grid interprets a null on params.success as explicitly remove the existing grand total row, so forward it as undefined instead to keep the previously cached total intact.
Getting Grand Total Data asynchronously
The grand total can be fetched on a separate endpoint so page loads don't wait for the aggregation. Use queryBuilder.getGrandTotalData(request) to compute it.