Hi,
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:
{
"Data"
:[{
"Id"
:5,
"ItemId"
:4,
"Datum"
:
"\/Date(1447023600000)\/"
,
"CountOk"
:3}],
"Total"
:1,
"AggregateResults"
:[{
"Value"
:3,
"Member"
:
"CountOk"
,
"FormattedValue"
:3,
"ItemCount"
:0,
"Caption"
:
null
,
"FunctionName"
:
"Sum_CountOk_21409671"
,
"AggregateMethodName"
:
"Sum"
}],
"Errors"
:
null
}
Thank you so much for helping me out here!