Reputation: 1594
I am trying to sum a column on a kendo grid, the datasource is not server side data, and the column is defined like this.
data-columns="[
...
{ 'field': 'owing', title: 'Balance Owing', format: '{0:c}', aggregates:['sum'],attributes: { style: 'text-align: right;'},groupFooterTemplate:'#= sum #' },
...
And the datasource has grouping and aggregates added like this
selectedTransactions.group({
field: "company",
aggregates: [
{ field: "owing", aggregate: "sum" }
]
});
selectedTransactions.aggregate([{ field: "owing", aggregate: "sum" }]);
I can't find anything else in kendo or anywhere saying I need to add more, but I am gettign an exception
Uncaught ReferenceError: sum is not defined
Upvotes: 1
Views: 4570
Reputation: 71
Here in kendo grid sum keyword is use here as variable so you Just Declared sum variable in var sum = 0; top of the code when we use sum then sum keyword declared as local variable
Upvotes: -1
Reputation: 4137
What you need to do is add aggregate in your datasource:
aggregate: [ { field: "owing", aggregate: "sum" } ],
and then in your columns add a footer template to collect the sum of the entire column:
{ field: "owing", title: "Total Price", footerTemplate: "Total Amount: #=sum#" }
Upvotes: 2