The DataGrid can calculate custom summaries on the client or server side. In this demo, we have implemented client-side logic. The instructions below explain how to do this in your code:
Make sure that the remoteOperations.summary, remoteOperations.groupPaging, or remoteOperations property is not set or set to false.
Add a summary configuration object to the summary.groupItems or summary.totalItems array.
Set the object's summaryType to "custom".
Specify the summary's name. It will be used to identify the summary item within the calculateCustomSummary function in the next step.
Calculate the resulting value in the calculateCustomSummary function. Implement the necessary calculation stages. See the function's description for details.
The custom summary in this example calculates the sum of sale amounts for selected rows. To recalculate the resulting value when selection is changed, the code calls the refresh() method in the onSelectionChanged handler.
Client-side custom summaries are suitable for small datasets. If your tests show that client-side calculations result in noticeable lags, we recommend that you use Server-Side Data Aggregation.