jqGrid 和 jqPivot:如何汇总在 ydimension 中指定的数据透视列并使用计数方法进行聚合?

jqGrid and jqPivot: How to sumary pivot column specify in ydimension and aggregates with count method?

我将 jqGrid 与 jqPivot 结合使用。

这是我的代码:

$("#pvtCrewAttendance").jqGrid("jqPivot",
            data,
            {
                footerTotals: true,
                footerAggregator: "sum",
                totals: true,
                totalText: "Sumary",
                xDimension: [
                    { dataName: "CategoryName", label: "Category Name", sortorder: "desc", footerText: "Row total" },
                ],
                yDimension: [
                    { dataName: "ProductName", sorttype: "text", totalHeader: "Total in {0}" },
                ],
                aggregates: [
                    { member: "ProductName", aggregator: "count" }
                ]
            },
            // grid options
            {
                iconSet: "fontAwesome",
                cmTemplate: { autoResizable: true, width: 80 },
                shrinkToFit: false,
                autoresizeOnLoad: true,
                autoResizing: { compact: true },
                pager: false,
                rowNum: 20,
                width: 420,
                height: 100,
                rowList: [5, 10, 20, 100, "10000:All"],
                caption: "Selling statistic"
            }
        );

这是我的蠢话 demo

我想汇总最后一列中每个类别的产品数量。

有什么办法吗?

我认为这是代码 jqPivotthe line 中的错误。我会在接下来的几天内修复它。作为解决方法,我建议您使用 aggregator defined as function:

aggregates: [
    {
        member: "ProductName",
        template: "integer",
        aggregator: function (options) {
            // do the same like aggregator: "count"
            return options.previousResult + 1;
        }
    }
]

对应的演示https://plnkr.co/edit/fz66phRoOLXWOuqTxF8g?p=preview显示

"Cols total" 列具有正确的 count 个结果。