SlickGrid Display Aggregation at grouping level

自作多情 提交于 2019-12-23 22:30:26

问题


I am following this example for grouping with aggregation: http://mleibman.github.io/SlickGrid/examples/example-grouping.html

This has grouping done in one row and Aggregation done in separate row. I want both to be displayed in same instead of having two separate rows

For e.g In above exampple i want to a single row to like + Duration : 3 (4 items) avg: 20 % cost:60 And then we click on expand button we see all details inside it.

Any suggestions?


回答1:


You need to change the formatter and the lazyTotalsCalculation.

  • lazyTotalsCalculation = false

    formatter: function (g) {
      var total = sumTotalsFormatter(g.totals, columns[6]),
          avg = avgTotalsFormatter(g.totals, columns[3]);
      return "Duration:  " + g.value + "  <span style='color:green'>(" + g.count + " items)</span><span>avg: " + avg + "</span><span> cost: " +  (total.length>0?total.split(":")[1] : total) + "</span>" ;
    },
    

That is the quick and dirty route. To make the code more robust instead of "hardcoding" the column index, you'll want to lookup the columns along the lines of:

grid.getColumns()[grid.getColumnIndex("cost")]
grid.getColumns()[grid.getColumnIndex("%")]


来源:https://stackoverflow.com/questions/24132043/slickgrid-display-aggregation-at-grouping-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!