Search code examples
jqgridfree-jqgridjqpivot

Remove blank column in jqGrid - Pivot


I have created a jqGrid - Pivot table JSFiddle example: here.

In this It should not print the line if Component Type value is blank, I Used this empty column, to show all periods(months) in the year, which is mandatory.

Need help in removing that blank line. and also is it possible to remove the last sum column 2015 from grid, if so how?


Solution

  • You includes dummy data with ComponentType:"" group which you don't want to display. So the best solution which I see would be to include the data in the input pivot data only, but don't use the dummy data in the grid data. jqPivot uses datatype: "jsonstring" to prevent additional sorting of previously sorted data. The input data will be placed as the value of datastr option. So one can use the following onInitGrid to remove the dummy data before the data will be processed by jqGrid:

    onInitGrid: function () {
        var p = $(this).jqGrid("getGridParam"),
            userdata = p.datastr.userdata;
    
        p.datastr = $.grep(p.datastr, function (item) {
            return item.ComponentType !== "";
        });
        p.datastr.userdata = userdata;
    }
    

    see the modified demo http://jsfiddle.net/OlegKi/b47ocLd7/11/.