1

This sample uses jqGrid 4.6:

http://jsfiddle.net/aUDHx/1218/

As one can see, regardless of the number of aggregates, the header names are displayed correctly ("A A", "A B", etc.)

However, when I switch to version 4.7, the pivoted columns aren't named correctly when more than one aggregate is used:

http://jsfiddle.net/aUDHx/1219/

If only one aggregate is used, the headers display correctly.

Does 4.7 have a different method of specifying the header names, or is this a bug? If the latter, does an appropriate workaround exist?

This is the code for the yDimension:

yDimension: [{
        dataName: 'product',
        converter: function (val) {return val.replace(/\s/g, ' ');}
    }],

The converter function is used to correctly format the header name. This is not required in 4.7 if you only use one aggregate, but anything more than that causes it to break.

"Gurrido" is now the new name of jqGrid.

ilitirit
  • 16,016
  • 18
  • 72
  • 111

1 Answers1

2

The problem is in spaces which you use in names. jqPivot don't support currently spaces in the names. You can fix the problem by replacing the spaces to _ (underscore) for example. I described the workaround here.

By the way Gurrido jqGrid is not the only successor of free open source jqGrid with MIT licence. After starting Gurrido jqGrid some other jqGrid forks of the last free jqGrid is developing. I post my results here. I plan to publish new version probably in the current month. Another fork you can find here. One apply in the fork many changes which I make in my repository, but one make some his own changes too.

UPDATED: The problem with the labels which you described is a bug in jqGrid 4.7. By the way you don't need to use the converter in case of usage spaces in the aggregation values.

I posted the bug fix here in my jqGrid repository. You can see the results on the demo http://jsfiddle.net/OlegKi/b47ocLd7/

enter image description here

The demo uses the following JavaScript code

var mydata = [
    { id: "1", product: "A A", sold: "8", sold2: "8", sold3: "8", emp: "Michelle" },
    { id: "2", product: "A A", sold: "3", sold2: "8", sold3: "8", emp: "Tania" },
    { id: "6", product: "A B", sold: "1", sold2: "8", sold3: "8", emp: "Mark" },
    { id: "3", product: "A B", sold: "5", sold2: "8", sold3: "8", emp: "Tommy" },
    { id: "4", product: "B B", sold: "2", sold2: "8", sold3: "8", emp: "Dave" },
    { id: "5", product: "B B", sold: "5", sold2: "8", sold3: "8", emp: "Carol" }
];

$("#grid").jqGrid("jqPivot", mydata, {
        xDimension: [
            { isGroupField: false, width: 40, dataName: "id",  label: "ID" },
            { isGroupField: false, width: 80, dataName: "emp", label: "Employee" }
        ],
        yDimension: [
            { dataName: "product" }
        ],
        aggregates: [
            { aggregator: "sum", width: 60, member: "sold",  label: "Sold" },
            { aggregator: "sum", width: 60, member: "sold2", label: "Sold 2" }
        ],
        colTotals: true
    },
    {
        height: "auto",
        pager: "#pager",
        iconSet: "fontAwesome",
        resizeStop: function () {
            $(this).jqGrid("setGridWidth", this.grid.newWidth, false);
        },
        caption: "Daily Sales"
    }
);
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Even if I replace the spaces in the the header names, it still adds _sumX to the name. – ilitirit Feb 04 '15 at 21:44
  • @ilitirit: Sorry, but you included in the demo the values with spaces which has no relation to your problem. Moreover you use **different code** in two demos (4.7 and 4.6), so the results are different not only in the header. It was the reason of my answer. Now I understand that the only problem which you have is in the **column headers** (is it really so?). I will debug jqGrid code of 4.7 later and will append my answer with the results of my investigations. I can do this only later. – Oleg Feb 05 '15 at 07:46
  • Oleg - good to know about your fork. I may want to use it instead of the gurrido, what's the best way to get help from you? We may also have some contributions as we've made some mods to the (original) source as well (mostly small things). – Bean Mar 06 '15 at 14:34
  • @Bean: If you will find any problem you can post an issue [here](https://github.com/free-jqgrid/jqGrid/issues). For general help questions you can post questions on stackoverflow. You can continue to use [jqgrid](http://stackoverflow.com/tags/jqgrid/info) tag or add `[free-jqgrid]` additionally. – Oleg Mar 06 '15 at 14:46
  • 1
    @Bean: I published recently 4.8 version of my fork. Just now the sorces are added to cdnjs too: see [here](https://github.com/OlegKi/cdnjs/commit/d166670b19a6a9ba3f3a3fb56afc79bd6c725d5d). So you can use `//cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/css/ui.jqgrid.css`, `//cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/js/jquery.jqgrid.min.js` and optionally `//cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.8.0/js/i18n/grid.locale-en.js`. I'll update [wiki](https://github.com/free-jqgrid/jqGrid/wiki). – Oleg Mar 06 '15 at 14:49
  • Awesome, thanks. I was just looking at your demos and already super happy with what I'm seeing...especially the multiline pager...that looks GREAT! – Bean Mar 06 '15 at 14:55
  • @Bean: You are welcome! I would recommend you to include [Font Awesome](http://fontawesome.io/) in your project too and add `iconSet: "fontAwesome"` option (see [here](https://github.com/free-jqgrid/jqGrid/wiki/Using-Font-Awesome-in-free-jqGrid-4.8) for details). I recommend you to read [the post](https://github.com/free-jqgrid/jqGrid/wiki/SMALL-improvements-in-the-usage-of-jqGrid) and [this one](https://github.com/free-jqgrid/jqGrid/wiki/New-style-of-usage-options-of-internal-methods) and other articles in wiki. You can improve the text of wiki, because the wiki is **public editable** now. – Oleg Mar 06 '15 at 15:01