我发现这个问题很有趣,所以我创建了the demo,它演示了两行页脚的可能实现:
主要思想是在已经存在标准页脚的表格中添加第二行。为了消除 jqGrid 代码的其他部分可能出现的问题,我将自定义行中的 footrow 类名替换为 myfootrow。为了使第二个页脚的 CSS 设置与原始图腾相同,我包含了来自 ui.jqgrid.css 的 .ui-jqgrid tr.footrow td 的副本,并具有与 .ui-jqgrid tr.myfootrow td 相同的定义:
.ui-jqgrid tr.myfootrow td {
font-weight: bold;
overflow: hidden;
white-space:nowrap;
height: 21px;
padding: 0 2px 0 2px;
border-top-width: 1px;
border-top-color: inherit;
border-top-style: solid;
}
您将在下面找到完整的代码
footerrow: true,
loadComplete: function () {
var $this = $(this),
sum = $this.jqGrid("getCol", "amount", false, "sum"),
$footerRow = $(this.grid.sDiv).find("tr.footrow"),
localData = $this.jqGrid("getGridParam", "data"),
totalRows = localData.length,
totalSum = 0,
$newFooterRow,
i;
$newFooterRow = $(this.grid.sDiv).find("tr.myfootrow");
if ($newFooterRow.length === 0) {
// add second row of the footer if it's not exist
$newFooterRow = $footerRow.clone();
$newFooterRow.removeClass("footrow")
.addClass("myfootrow ui-widget-content");
$newFooterRow.children("td").each(function () {
this.style.width = ""; // remove width from inline CSS
});
$newFooterRow.insertAfter($footerRow);
}
$this.jqGrid("footerData", "set", {invdate: "Total (page):", amount: sum});
// calculate the value for the second footer row
for (i = 0; i < totalRows; i++) {
totalSum += parseInt(localData[i].amount, 10);
}
$newFooterRow.find(">td[aria-describedby=" + this.id + "_invdate]")
.text("Grand Total:");
$newFooterRow.find(">td[aria-describedby=" + this.id + "_amount]")
.text($.fmatter.util.NumberFormat(totalSum, $.jgrid.formatter.number));
}
在代码中,我在页脚的invdate 和amount 列中设置了附加信息。