I need to create a three footer row in jqrid (the idea is to show 3 totals line at the end of the grid). In order to achieve that I fallow this post How to create two footer rows in jqgrid which is really useful from Oleg.
The thing is that I made some changes in his code to show 3 totals lines and is working fine when is the first load of the data, but if you click on next page or any other action it will show the 3 totals lines but on of those is repeated, so i'm loosing the second total.
This is my code:
loadComplete: function () {//for showing default edit
var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length;
//In order to have three totals
var $this = $(this),
$footerRow = $(this.grid.sDiv).find("tr.footrow"),
$secondFooterRow,$thirdFooterRow;
var f = '$'+{!optyObj.Otter_FFA_Total_Before_GST__c};
var m = '$'+{!optyObj.Otter_FFA_Grand_Total_GST__c};
var l = '$'+{!optyObj.Otter_FFA_Grand_Total_After_GST__c};
$secondFooterRow = $(this.grid.sDiv).find("tr.myfootrow");
$thirdFooterRow = $(this.grid.sDiv).find("tr.myfootrow");
if ($secondFooterRow.length === 0) {
// add second row of the footer if it's not exist
$secondFooterRow = $footerRow.clone();
$secondFooterRow.removeClass("footrow").addClass("myfootrow ui-widget-content");
$secondFooterRow.children("td").each(function () {
this.style.width = ""; // remove width from inline CSS
});
$secondFooterRow.insertAfter($footerRow);
}
if ($thirdFooterRow.length === 0) {
// add second row of the footer if it's not exist
$thirdFooterRow = $secondFooterRow.clone();
$thirdFooterRow.removeClass("footrow").addClass("myfootrow ui-widget-content");
$thirdFooterRow.children("td").each(function () {
this.style.width = ""; // remove width from inline CSS
});
$thirdFooterRow.insertAfter($secondFooterRow);
}
//FIRST FOOTER ROW
$this.jqGrid("footerData", "set", {Description1__c: "Total EX GST:", Otter_FFA_Total_Price__c:f});
//$this.jqGrid("footerData", "set", {Description1__c: "Total XXX GST:", Otter_FFA_Total_Price__c:f});
//SECOND FOOTER ROW
$secondFooterRow.find(">td[aria-describedby=" + this.id + "_Description1__c]").text("GST:");
$secondFooterRow.find(">td[aria-describedby=" + this.id + "_Otter_FFA_Total_Price__c]").text(m);
//THIRD FOOTER ROW
$thirdFooterRow.find(">td[aria-describedby=" + this.id + "_Description1__c]").text("Total INC GST:");
$thirdFooterRow.find(">td[aria-describedby=" + this.id + "_Otter_FFA_Total_Price__c]").text(l);
}
Here it is how it looks with the first load of the page:
Total EX GST: $1,141.12
GST: $114.14
Total INC GST: $1255.26
Page
2 of 2
View 11 - 12 of 12
And this how it looks when I click on next page or any other action:
Total EX GST: $1,141.12
Total INC GST: $1255.26
Total INC GST: $1255.26
Page
2 of 2
View 11 - 12 of 12
Any advice will be really appreciate it. I'm using this jqgrid in Salesforce but in the end is just a HTML page. I wanted to upload the images but i'm new in the community, so I can't.
Thanks.