How to display jqPivot Group header in Orderby

558 Views Asked by At

Here is the Example created - Pivot Table JSFiddle example: here

groupingView: {
        groupField: ['ComponentType'],
        groupColumnShow: [false],
        groupDataSorted: true,
        groupOrder: "desc"
    }, /*Is not working properly, when i click sort on ComponentType, group headers are not sorting*/

Need help to display ComponentType(group header) in desc order.

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

First of all you have to fix the grouping options options which you use. You have to use

groupOrder: ["desc"]

instead of

groupOrder: "desc"

The main problem with ignoring of "desc" grouping order exist already in old version of jqGrid (see the line of jqGrid 4.6 and the line of jqGrid 4.7).

I fixed the code in free jqGrid. The demo which uses the latest version of free jqGrid from GitHub don't have more the described problem: https://jsfiddle.net/OlegKi/bkqce0s0/11/

If you have to use old version of free jqGrid of jqGrid then you can solve the problem by changing datatype from "jsonstring" to "local":

onInitGrid: function () {
    var p = $(this).jqGrid("getGridParam"),
        userdata = p.datastr.userdata;

    // filter the data and remove some items
    p.data = $.grep(p.datastr, function (item) {
        return item.ComponentType !== "";
    });

    p.userData = userdata;
    p.datatype = "local";
}

The demo http://jsfiddle.net/OlegKi/bkqce0s0/12/