easyui-datagrid计算汇总
<style type="text/css">.subtotal { font-weight: bold; }/*合计单元格样式*/</style><script type="text/javascript">function onLoadSuccess() {//添加“合计”列$('#table').datagrid('appendRow', {Saler:
·
1.easyui datagrid经常使用到汇总列,为了方便统计数据,可直接写标准的通用函数,来计算数据的结果。
<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>

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)