Aggregate with aspnetmvc-ajax result

2 posts, 1 answers
  1. Christian
    Christian avatar
    38 posts
    Member since:
    Jul 2014

    Posted 10 Nov 2015 Link to this post


    I need some help with the aggregate feature please. The sum aggregates are not displayed at the footer of the grid. The correct data is received however.

    I Have an MVC backend and use the DatasourceRequest object, but because of the fact I am using angular, I cannot work with the MVC wrappers. Therefore I use the following JS for the grid options:

    $scope.gridOptions = {
                    // 1. DATASOURCE
                    "dataSource": {
                        "type": 'aspnetmvc-ajax',
                        "transport": {
                            "read": { "url": myReadUrl() },
                            "update": { "url": myUpdateUrl() },
                            "create": { "url": myCreateUrl() },
                        "serverPaging": true,
                        "pageSize": 20,
                        "serverSorting": true,
                        "serverFiltering": true,
                        "sort": { "field": "Datum", "dir": "desc" },
                        "schema": {
                            model: {
                                "id": "Id",
                                "fields": {
                                    "Id": { "type": "number" },
                                    "Datum": { "type": "date", validation: { required: true } },
                                    "​CountOk": { "type": "number", "validation": { required: true, min: 0 } },
                            "data": "Data",
                            "total": "Total",
                            "errors": "Errors",
                            "aggregates": "AggregateResults"
                        "serverAggregates": true,
                        "aggregate": [field: "​CountOk", aggregate: "sum" },  ]
                    // 2. COLUMNS
                    "columns": [
                            "title": "Date",
                            "field": "Datum",
                            "format": "{0:d}",
                        }, {
                                    "title": "OK",
                                    "field": "CountOk",
                                    "width": 100,
                                    "format": "{0:0}",
                                    "aggregates": ["sum"],
                         }, {
                            "command": [
                                { "name": "edit", "buttonType": "ImageAndText" },
                    // 3. GRID FEATURES
                    "editable": {
                        "mode": "inline",
                        "create": true,
                        "update": true,
                        "destroy": false
                    "toolbar": [
                        { "name": 'create', "buttonType": "ImageAndText", "text": "​New" },
                    "pageable": true,
                    "sortable": true,
                    "scrollable": true,


     The received data contains the values, but it seems MVC datasource added some things here:



    Thank you so much for helping me out here!


  2. Answer
    Daniel avatar
    2224 posts

    Posted 12 Nov 2015 Link to this post


    You should add a footerTemplate to the column in order to display the sum:
        "title": "OK",
        "field": "CountOk",
        "width": 100,
        "format": "{0:0}",
        "aggregates": ["sum"],
        footerTemplate: "#:sum#"
    Also, note that the schema.aggregates option should not be set. The 'aspnetmvc-ajax' dataSource uses its own predefined function that converts the aggregates result in the expected format.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top