jqGrid列的统计
作者:互联网
function GetGrid() { var selectedRowIndex = 0; var $gridTable = $('#gridTable'); $gridTable.jqGrid({ autowidth: true, height: $(window).height() - 136.5, url: "xxx/yyyy/zzzz", postData: { 参数1: 参数1, 参数1: 参数1}, datatype: "json", colModel: [ { label: '参数1', name: '参数1', index: '参数1', width: 100, align: 'left', sortable: true, hidden: true }, { label: '名字', name: 'Name', index: 'Name', width: 250, align: 'left' }, { label: 'pay1', name: 'pay1', index: 'pay1', width: 150, align: 'left' }, { label: 'pay2', name: 'pay2', index: 'pay2', width: 100, align: 'left' }, { label: 'pay3', name: 'pay3', index: 'pay3', width: 100, align: 'left' }, { label: '日期', name: 'Date', index: 'Date', width: 130, align: 'left', formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } } ], viewrecords: true, rownumbers: true, shrinkToFit: false, gridview: true, footerrow: true, rowNum: -1, onSelectRow: function () { selectedRowIndex = $('#' + this.id).getGridParam('selrow'); }, gridComplete: function () { $('#' + this.id).setSelection(selectedRowIndex, false); var total_pay1=$gridTable.getCol('pay1',false,'sum'); var total_pay2= $gridTable.getCol('pay2', false, 'sum'); var total_pay3=$gridTable.getCol('pay3',false,'sum'); $gridTable.footerData("set", { "Name": '合计', pay1: total_pay1, pay2: total_pay2, pay3: total_pay3}); }, subGrid: true, //子表格的id;当子表格展开的时候,在主表格中会创建一个div元素用来容纳子表格,subgrid_id就是这个div的id subGridRowExpanded: function (subgrid_id, row_id) {//子表格容器的id和需要展开子表格的行id bindSubGrid(subgrid_id, row_id); } });
注意:以面红色文字,要一一对应,底部统计数量会对应的列显示总计
footerrow: true 开启底部显示
标签:gridTable,pay2,pay3,pay1,true,id,统计,jqGrid 来源: https://www.cnblogs.com/qingjiawen/p/13529406.html