SlickGrid在分组级别显示聚合 [英] SlickGrid Display Aggregation at grouping level
问题描述
我正在按照此示例进行聚合分组:
http: //mleibman.github.io/SlickGrid/examples/example-grouping.html
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
例如在上面的示例中我想要一行就像
+ 持续时间:3(4项) 平均:20%费用:60
然后我们点击展开按钮我们看到全部里面有详细信息。
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.
有什么建议吗?
推荐答案
你需要更改格式化程序
和 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("%")]
这篇关于SlickGrid在分组级别显示聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!