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

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

相关文章:

  • 2021-11-17
  • 2021-12-05
  • 2021-10-09
  • 2021-10-31
  • 2021-12-03
  • 2021-08-26
  • 2022-02-10
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-07-22
  • 2022-03-01
  • 2021-08-14
  • 2022-01-16
相关资源
相似解决方案