Reputation: 41
I exactly followed the examples on Kendo UI's website. All data shows fine, but all the operation of "sum" not happening. So in the groupFooterTemplate, all columns shows the last item in the grid including the "average" column. I have been working on this for a few days and just cannot figure out what went wrong. Did this happen to anyone?
$scope.vmResyncGridOptions = {
dataSource: {
data: $scope.vmDataSource,
scheme: {
model: {
id: "vmName",
fields: {
vmName: { type: "string" },
vdiskName: { type: "string" },
total: { type: "number" },
synced: { type: "number" },
percent: { type: "number" }
}
}
},
group: {
field: "vmName",
aggregates: [
{ field: "vdiskName", aggregate: "count" },
{ field: "total", aggregate: "sum" },
{ field: "synced", aggregate: "sum" },
{ field: "percent", aggregate: "average" }
]
},
aggregate: [
{ field: "vdiskName", aggregate: "count" },
{ field: "total", aggregate: "sum" },
{ field: "synced", aggregate: "sum" },
{ field: "percent", aggregate: "average" }
]
},
sortable: false,
scrollable: true,
pageable: true,
groupable: true,
//height: ($scope.screenHeight-110)*0.70-8,
columns: [
{
field: "vdiskName",
title: $scope.translation.Resync_Table_VDisk_Name,
aggregates: ["count"],
groupFooterTemplate: "Count: #=count#"
},
{
field: "total",
title: $scope.translation.Resync_Table_Total_Bytes,
aggregates: ["sum"],
groupFooterTemplate: "Total: #=sum#"
},
{
field: "synced",
title: $scope.translation.Resync_Table_Has_Resynced,
aggregates: ["sum"],
groupFooterTemplate: "Total Resynced: #=sum#"
},
{
field: "percent",
title: $scope.translation.Resync_Table_VDisck_Completed,
aggregates: ["average"],
groupFooterTemplate: "Percent: #=average#"
}
]
};
Upvotes: 4
Views: 4400
Reputation: 51
Initially check all the table data. There is a possibility of spaces or newline characters in the table columns. Even if the columns, which are not aggregated. After the changes recheck the solution.
Upvotes: 1
Reputation: 1
The issue here is that the data is only cast according to the datasource schema (i.e. type: "number") during transport operations. In your case, I'm assuming you're applying the data directly using the Datasource.data([array]) method. When you apply the data yourself, the datatypes in your supplied array are preserved. So, if you pass a numberic value as a string, it will remain as a string in the datasource despite the model indicating that it should be a number. Numeric data that is cast as a string will not sum; only the last value will be returned. Look at the data you're trying to sum; see what datatype it is within the datasource. My guess is that if you're only seeing the last value then your datatype is a string.
Upvotes: 0
Reputation: 1466
You group by the same column as the datasource id:
id: "vmName",
fields: {
vmName: { type: "string" },
vdiskName: { type: "string" },
total: { type: "number" },
synced: { type: "number" },
percent: { type: "number" }
}
}
},
group: {
field: "vmName",
Thats why you don't get sum and averages.
Upvotes: 0