我有一个函数可以计算特定列的摘要并将其加载到网格的页脚中。这是代码..
$(function () {
var gridData = null;
var nn = null;
grid = $("#gridId"),
calculateTotal = function () {
var gridData = grid.jqGrid('getGridParam', 'data'),
i = 0, totalAmount = 0, totalduration = 0;
for (; i < gridData.length; i++) {
var rowData = gridData[i];
totalAmount += Number(rowData.price);
totalduration += Number(rowData.duration);
}
grid.jqGrid('footerData', 'set', { name: "TOTAL", duration: totalduration, price: totalAmount });
};
});
现在我在这里调用这个摘要函数......
$.ajax({
url: 'Default.aspx/MyMethod',
dataType: 'json',
contentType: "application/json; charset=utf-8",
type: 'POST',
success: function (ReportDataNew, textStatus, XMLHttpRequest) {
//debugger;
gridData = JSON.parse(ReportDataNew.d);
console.log(gridData);
//alert(gridData.length);
$("#gridId").jqGrid({
data: gridData,
datatype: "local",
height: '100%',
autowidth: true,
ignoreCase: true,
rowNum: 50,
rowList: [50, 100, 200],
colNames: ['UserName', 'Duration', 'Destination', 'Price'],
colModel: [
{ name: 'username', index: 'username', width: 100, sortable: true, align: 'center' },
{ name: 'duration', index: 'duration', width: 100, sortable: true, align: 'center' },
{ name: 'destination', index: 'destination', width: 100, sortable: true, align: 'center' },
{ name: 'price', index: 'price', width: 100, sortable: true, align: 'center', formatter: 'currency' }
],
pager: '#gridpager',
viewrecords: true,
toppager: true,
loadtext: 'Loading...',
footerrow: true,
userDataOnFooter: true,
loadComplete: function () {
calculateTotal();
}
});
但是在从过滤器工具栏过滤记录时,页脚行的汇总值保持不变......我需要在从过滤器工具栏过滤或搜索后更新页脚的汇总值......
任何帮助将不胜感激/。提前谢谢..