jqGrid different summaries on different group leve

2019-05-18 16:11发布

I want to create different summaries on different group levels in an jqGrid, like this:

custom summeries jqGrid Image is based on this demo: http://www.guriddo.net/demo/guriddojs/grouping/multiple_columns/index.html

On the top level group I would like jqGrid to calculate an average and on the lower level groups it would calculate a sum.

Is this possible in jqGrid?

1条回答
Rolldiameter
2楼-- · 2019-05-18 16:42

The main problem which I see: you need to use different summaryType ("sum" and "avg") on different levels of the grid. There are no simple way to implement this. I think it's possible, but the code will be not simple. The code can depends on version of jqGrid, which you use and from the fork (free jqGrid, Guriddo jqGrid JS of some old version <=4.7).

To place result in header is easy you need just add groupSummaryPos: ["header", "header"] property in groupingView. You should set either summaryType: "sum" or summaryType: "avg" in the column Freight.

UPDATE: I implemented new feature in free jqGrid. Now one can use summaryType and summaryTpl defined as arrays. The demo have Total column defined as

{ name: "total", width: 75, template: "number",
    summaryTpl: [
        "<span style='color: red'>Avg: {0}</span>",
        "<span style='color: DarkRed'>Sum: {0}</span>"
    ],
    summaryType: ["avg", "sum"] },

The results of the demo looks like on the picture:

enter image description here

I have to remark, that the changes are not included in free jqGrid 4.10.0, which I published today, so you have to use the sources from GitHub to be able to use the feature.

查看更多
登录 后发表回答