1

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?

Oleg
  • 220,925
  • 34
  • 403
  • 798
Mani Deep
  • 1,298
  • 2
  • 17
  • 33

1 Answers1

0

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/.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • @ManiDeep: Sorry, but how the blank line can come again if no data exist in the grid? Do you do something like http://jsfiddle.net/OlegKi/b47ocLd7/13/? I don't see any problems. – Oleg Apr 21 '15 at 09:42
  • @ManiDeep: You placed `loadComplete` in your last demo on absolutely wrong place. The 3-d parameter of `jqPivot` specify jqGrid options. You included `{ loadComplete: function() {...} }` and the options where `onInitGrid` are used will be now in **the 4-d parameter** of `jqPivot` and will be interpreted as Ajax options. So `onInitGrid` which I suggested will be not used. You should use something like http://jsfiddle.net/OlegKi/b47ocLd7/16/. – Oleg Apr 21 '15 at 09:56
  • oh.. sorry i didnt knew that.. yea it is wokring, and from your example http://stackoverflow.com/a/14694528/2750968 here , even font-weight:bold of header is not working :( – Mani Deep Apr 21 '15 at 09:59
  • and if u can share a link of the using parameters of jquery.. itll be usefull :) thanks – Mani Deep Apr 21 '15 at 10:00
  • omg I just noticed, the summary (sum values at the bottom of grid are not loading) from the main answer u sent.. – Mani Deep Apr 21 '15 at 10:04
  • @ManiDeep: Sorry, but I don't understand the last problem. You use **grouping of data**. [The old answer](http://stackoverflow.com/a/14694528/2750968) shows how to set **bold** style in **TreeGrid**. Tree grid elements have `parent` property which is the id of parent row or `"null"` for the root nodes. Thus the answer uses `rd.parent === "null"` to set the class on the nodes. – Oleg Apr 21 '15 at 10:05
  • is it possible to add sorting option to `Component Type` aswell? as it is for all the measures and component name ? – Mani Deep Apr 21 '15 at 11:18
  • 1
    @ManiDeep: You should change `groupingView.groupOrder` dynamically if the user click on sorting of column from `groupingView.groupField` array. The problem exist only if `groupingView.groupColumnShow` contains `true` element. Typically one uses `groupingView.groupColumnShow: [false]` and there are no column for the grouping column at all. – Oleg Apr 21 '15 at 12:38
  • Here, if the blank line without component type has a value, then that line's value is also being added in the overall sum at footer of grid.. (but we have removed it from display), how to ignore its value also from being added? as in this JSFiddle: http://jsfiddle.net/manideep/bkqce0s0/2/ (jan-15 has no records, we reomved from disply, but still has value in summary footer) – Mani Deep Apr 21 '15 at 12:40
  • @ManiDeep: I don't understand what you mean. You wrote that you added dummy rows only to have more columns. Why the values could exist? The Pivot generates columns of jqGrid and calculates in the same time the summary results. If you want, you can change the values from the footer row inside of `onInitGrid`. The `userdata` is the object with the footer values. So you can reduce the value on the values from removed rows (rows where `item.ComponentType !== ""`). – Oleg Apr 21 '15 at 12:48
  • can you please join group: http://chat.stackoverflow.com/rooms/75790/discussion-between-mani-deep-and-oleg – Mani Deep Apr 21 '15 at 12:48
  • @ManiDeep: Sorry, but I spent already too many time for your questions. I have other things to do. – Oleg Apr 21 '15 at 12:52
  • ohk, actually it was not related to this question. @Oleg thanks for your time – Mani Deep Apr 21 '15 at 12:53