赞
踩
$('#teaTable').datagrid({
url : contextPath + '/a/nursetrain/teacher/findTeaStatisticsList',
queryParams: {
"searchType" : searchType
},
pagination: true,
toolbar:'#div_teaTable_toobar',
onLoadSuccess:function (){
compute(searchType)
},
pageSize: 10,
pageList: [5, 10, 20],
columns: columnsArray
});
所有行的值相加
function compute(searchType) { //计算函数 var rows1 = $('#teaTable').datagrid('getRows')//获取当前的数据行 $.ajax({ url : contextPath + '/a/nursetrain/teacher/findTeaStatisticsList', data: { searchType:searchType, page: "1", rows: $('#teaTable').datagrid('getData').total } ,type: "get" ,async: false ,dataType: "json" ,success: function (datas) { console.log(datas) rows1 = datas.rows; //获取datagird的所有行 } }); var S_NUM1 = 0//计算listprice的总和 , SKLS_NUM1 = 0//统计unitcost的总和 , DJLS_NUM1 = 0//统计unitcost的总和 , TEA_NUM1 = 0;//统计unitcost的总和 for (var i = 0; i < rows1.length; i++) { S_NUM1 += parseFloat(rows1[i]['S_NUM']); SKLS_NUM1 += parseFloat(rows1[i]['SKLS_NUM']); DJLS_NUM1 += parseFloat(rows1[i]['DJLS_NUM']); TEA_NUM1 += parseFloat(rows1[i]['TEA_NUM']); } $('#teaTable').datagrid('appendRow',{ office_name: '<b>科室:</b>', SKLS_NUM: SKLS_NUM1, DJLS_NUM: DJLS_NUM1, S_NUM: S_NUM1, TEA_NUM: TEA_NUM1 }); }
当前页的行的值相加
function compute(searchType) { var rows = $('#teaTable').datagrid('getRows')//获取当前的数据行 var S_NUM = 0//计算listprice的总和 , SKLS_NUM = 0//统计unitcost的总和 , DJLS_NUM = 0//统计unitcost的总和 , TEA_NUM = 0;//统计unitcost的总和 for (var i = 0; i < rows1.length; i++) { S_NUM += parseFloat(rows[i]['S_NUM']); SKLS_NUM += parseFloat(rows[i]['SKLS_NUM']); DJLS_NUM += parseFloat(rows[i]['DJLS_NUM']); TEA_NUM += parseFloat(rows[i]['TEA_NUM']); } $('#teaTable').datagrid('appendRow',{ office_name: '<b>科室:</b>', SKLS_NUM: SKLS_NUM, DJLS_NUM: DJLS_NUM, S_NUM: S_NUM, TEA_NUM: TEA_NUM }); }
效果图
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。