jQuery easyUI datagrid 增加求和统计行的实现代码
在datagrid的onLoadSuccess事件增加代码处理。
<style type="text/css"> .subtotal { font-weight: bold; }/*合计单元格样式*/ </style> <script type="text/javascript"> function onLoadSuccess() { //添加“合计”列 $('#table').datagrid('appendRow', { Saler: '<span class="subtotal">合计</span>', TotalOrderCount: '<span class="subtotal">' + compute("TotalOrderCount") + '</span>', TotalOrderMoney: '<span class="subtotal">' + compute("TotalOrderMoney") + '</span>', TotalOrderScore: '<span class="subtotal">' + compute("TotalOrderScore") + '</span>', TotalTrailCount: '<span class="subtotal">' + compute("TotalTrailCount") + '</span>', Rate: '<span class="subtotal">' + ((compute("TotalOrderScore") / compute("TotalTrailCount")) * 100).toFixed(2) + '</span>' }); } //指定列求和 function compute(colName) { var rows = $('#table').datagrid('getRows'); var total = 0; for (var i = 0; i < rows.length; i++) { total += parseFloat(rows[i][colName]); } return total; } </script>
相关推荐
89427412 2020-02-13
morexyoung 2019-12-20
EdwardSiCong 2015-04-11
ningwentao 2015-10-21
zderam的私人 2019-09-02
shanhuijava 2016-08-17
wndong 2016-03-04
AngelicaA 2015-12-22
xiaobozhu 2015-10-27
yypiao 2015-10-21
小策一喋 2015-09-17
小仙儿 2015-06-15
huzai 2015-06-03
huzai 2015-04-22
zhangmingming 2015-03-11
大数据实战派 2015-02-04
葉無聞 2015-01-01
sunnylinner 2014-12-19