1

I'm using jqGrid with the jqPivot.

Here my code:

$("#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"
            }
        );

This my plunk demo

I want to sumary quantity of product for each category in the last column.

Any way to do it?

Oleg
  • 220,925
  • 34
  • 403
  • 798
Tommy1209
  • 179
  • 3
  • 12

1 Answers1

1

I think it's a bug in the line of code jqPivot. I'll fix it in the next days. As a workaround I suggest you to use aggregator defined as function:

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

The corresponding demo https://plnkr.co/edit/fz66phRoOLXWOuqTxF8g?p=preview displays

enter image description here

with "Cols total" column having correct count results.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Great @Oleg, thank you very much. This problem has taken more than a day for me. @_@ – Tommy1209 Nov 24 '17 at 01:47
  • a small question more: Is there any way to bold the value of "Cols total" column – Tommy1209 Nov 24 '17 at 03:15
  • 1
    @Tommy1209: You are welcome! You can make the last column bold in different way. For example, the header of the total column have the name "t" and id of the column header built from grid id and the column name: `pvtCrewAttendance_t`. The cells of the column have attribute `aria-describedby=pvtCrewAttendance_t`. Thus one can use CSS rule `.ui-jqgrid tr.jqgrow>td[aria-describedby=pvtCrewAttendance_t], #pvtCrewAttendance_t { font-weight: bold; }`. See https://plnkr.co/edit/aWcjSYr7r7D3iw7jTTMv?p=preview – Oleg Nov 24 '17 at 05:57