Here is the Example created - Pivot Table JSFiddle example: here
Here are my grid options used:
{
cmTemplate: { autoResizable: true },
autoResizing: { compact: true },
width: "600",
height: "auto",
rowNum: 10,
iconSet: "fontAwesome",
pager: true,
caption: "Employee YTD Summary",
groupingView: {
groupColumnShow: [false],
groupDataSorted: true,
groupOrder: ["desc"]
},
onInitGrid: function () {
var p = $(this).jqGrid("getGridParam"),
userdata = p.datastr.userdata;
p.data = $.grep(p.datastr, function (item) {
return item.ComponentType !== "";
});
p.userData = userdata;
p.datatype = "local";
},
footerrow: true
}
Need help in Ignoring specific row's/groups in adding from colTotals
summary
This is the part of grid I have from above example
At footer of this Image colTotals
section shows sum of all columns, In here I am unable to exclude the groups Benefit
and AD
from being summed.
expected sum at colTotals
Working days, LOP, Benefits rows should not be summed (as they are not required) in summary column which is at bottom (red mark)
How to ignore complete group of AD
and Benefit
values in colTotals
summary
of jqGrid.
Thanks
It looks like you want to make custom calculation of the values in the total summary rows. In the You can for example remove colTotals: true
parameter. It makes only the standard calculation of the sum of all elements. Instead of that you can add userDataOnFooter: true
option, calculate the custom summary inside of onInitGrid
and to place the results in userdata
. The code can looks like the following
userDataOnFooter: true,
onInitGrid: function () {
var p = $(this).jqGrid("getGridParam"), userdata = {}, colModel = p.colModel,
iColByName = p.iColByName;
p.datastr = $.grep(p.datastr, function (item) {
var notToIgnore = item.ComponentType !== "", prop;
if (notToIgnore) {
for (prop in item) {
if (item.hasOwnProperty(prop) &&
iColByName[prop] != null &&
colModel[iColByName[prop]].summaryType === "sum" &&
// !!!below is the custom criteria to skip some items!!!
$.inArray(item.ComponentType, ["AD", "Benefit"]) < 0) {
userdata[prop] = (userdata[prop] || 0) + parseFloat(item[prop]);
}
}
}
return notToIgnore;
});
p.datastr.userdata = userdata;
}
You can see the results on the modified data: https://jsfiddle.net/OlegKi/bkqce0s0/14/