All docs
V19.1
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Custom Aggregate Function

Client-Side Data Aggregation

Follow the steps below to configure custom client-side data aggregation.

  1. Make sure that the remoteOperations.summary, remoteOperations.groupPaging, or remoteOperations option is not set or set to false.

  2. Add one or several summary items to the totalItems or groupItems array. Specify their names and set summary types to "custom":

    jQuery
    JavaScript
    $(function() {
        $("#dataGridContainer").dxDataGrid({
            // ...
            summary: {
                totalItems: [
                    { name: "сustomSummary1", summaryType: "custom" },
                    { name: "сustomSummary2", summaryType: "custom" }
                ]
            }
        });
    });
    Angular
    HTML
    TypeScript
    <dx-data-grid ... >
        <dxo-summary>
            <dxi-total-item
                name="сustomSummary1"
                summaryType="custom">
            </dxi-total-item>
            <dxi-total-item
                name="сustomSummary2"
                summaryType="custom">
            </dxi-total-item>
        </dxo-summary>
    </dx-data-grid>
    import { DxDataGridModule } from "devextreme-angular";
    // ...
    export class AppComponent {
        // ...
    }
    @NgModule({
        imports: [
            // ...
            DxDataGridModule
        ],
        // ...
    })
  3. Implement the calculateCustomSummary function as detailed in its description.

View Demo

See Also

Server-Side Data Aggregation

NOTE
This article applies to ASP.NET servers only.

Follow the instructions below to implement custom server-side data aggregation. This implementation requires the DevExtreme.AspNet.Data library.

  1. Set the remoteOperations.summary, remoteOperations.groupPaging, or remoteOperations option to true.

  2. Implement and register a custom server-side data aggregator using DevExtreme.AspNet.Data as described in this article.

  3. Pass the string identifier you used to register the aggregator to a summary item's summaryType option:

    ASP.NET MVC Controls
    Razor C#
    @(Html.DevExtreme().DataGrid()
        .RemoteOperations(true)
        .Summary(s => s
            .TotalItems(i => {
                i.Add().SummaryType("totalSales");
            })
        )
    )
    jQuery
    JavaScript
    $(function() {
        $("#dataGridContainer").dxDataGrid({
            remoteOperations: true,
            summary: {
                totalItems: [
                    { summaryType: "totalSales" }
                ]
            }
        });
    });
    Angular
    HTML
    TypeScript
    <dx-data-grid ...
        [remoteOperations]="true">            
        <dxo-summary>
            <dxi-total-item summaryType="totalSales"></dxi-total-item>
        </dxo-summary>
    </dx-data-grid>
    import { DxDataGridModule } from "devextreme-angular";
    // ...
    export class AppComponent {
        // ...
    }
    @NgModule({
        imports: [
            // ...
            DxDataGridModule
        ],
        // ...
    })