首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqGrid和jqPivot:如何使用计数方法在Y维和聚合中指定和支点列?

jqGrid和jqPivot:如何使用计数方法在Y维和聚合中指定和支点列?
EN

Stack Overflow用户
提问于 2017-11-23 02:23:29
回答 1查看 831关注 0票数 1

我用的是jqGrid和jqPivot。

这里我的代码:

代码语言:javascript
复制
$("#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"
            }
        );

这是我的演示

我想在最后一栏中总结每个类别的产品数量。

有什么办法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-23 21:12:21

我认为这是这条线 of code jqPivot中的一个bug。我会在接下来的几天里修好它。作为解决办法,我建议您使用定义为函数的aggregator

代码语言:javascript
复制
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总计“列具有正确的计数结果。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47446627

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档