问题
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
},
回答1:
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.
来源:https://stackoverflow.com/questions/35140813/slickgrid-grouped-header-showtotal