Slickgrid Grouped header ShowTotal

2019-07-14 05:35发布

How can I show the total average and total cost on Duration(Expanded/collapsed) row where number of items are instead of at the bottom in a separate row?

here is the fiddle for it http://jsfiddle.net/c76xW/3/

dataView.setGrouping([
    {
      getter: "duration",
      formatter :function (g) {
        return "Duration:  " + g.value + "  <span style='color:green'>(" + g.count + " items)</span>";
      },
      aggregators: [
        new Slick.Data.Aggregators.Sum("duration"),
        new Slick.Data.Aggregators.Sum("cost")
      ],
      aggregateCollapsed: true,
      lazyTotalsCalculation: true
    },

标签: css slickgrid
1条回答
Melony?
2楼-- · 2019-07-14 06:20

You would have to modify it a bit. JSfiddle link with updated code is here. Be careful with the aggregateCollapsed and lazyTotalsCalculation - they need to be set to true if you want to access the average and sum in that way, but it also means it will run slower since it's doing it for each and every group at the same time and not when the user is looking at them.

查看更多
登录 后发表回答