Using SlickGrid Aggregation / Column Amount

I'm just trying to summarize a column and display the total value at the bottom of the table. From looking at the examples, it seems that using an aggregator is the best way to do this. However, when I just add

dataView.setAggregators([ new Slick.Data.Aggregators.Sum("value") ], false);

Nothing happens. I worked for several hours just to create a simple aggregator based on the grouping example, but the grouping example is too complex for me to say exactly what I need.

Edit: Alternative fix: For someone else, I did not use aggregators. Data is available in Javascript, which makes life much easier. Total amounts can be calculated from there.

+5
source share
1 answer

, , ( ), , Grand Total ... , , , 3 , 1

1 ,

dataView.setAggregators([ new Slick.Data.Aggregators.Sum("value") ], false);

2nd ( ) , groupTotalsFormatter

var columns = [
  ...
  {id: "cost", name: "Cost", field: "cost", width: 90, sortable: true, groupTotalsFormatter: sumTotalsFormatter}
];

, ,

function sumTotalsFormatter(totals, columnDef) {
  var val = totals.sum && totals.sum[columnDef.field];
  if (val != null) {
    return "total: " + val;
  }
  return "";
}

- , , .

+3

All Articles