zoukankan      html  css  js  c++  java
  • jQuery easyUI datagrid 增加求和统计行 分类: JavaScript 2015-01-14 17:46 2178人阅读 评论(0) 收藏

    在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>

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    Python:dict用法
    Ubuntu无法识别显示器情况下,高分辨率的设置
    select节点clone全解析
    js控制frameset的rows
    jQuery中事情的动态绑定 (转)
    jQuery动态添加表格1
    使用ajax,后台传回的数据处理
    Spring Boot 之构建Hello Word项目
    linux防火墙基本操作
    Vmware虚拟机中安装cnetOS7详细图解步骤
  • 原文地址:https://www.cnblogs.com/zhangqs008/p/4687643.html
Copyright © 2011-2022 走看看