简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

jQuery easyUI datagrid 增加求和统计行的实现代码

来源:易贤网   阅读:3431 次  日期:2016-06-17 11:56:59

温馨提示:易贤网小编为您整理了“jQuery easyUI datagrid 增加求和统计行的实现代码”,方便广大网友查阅!

下面小编就为大家带来一篇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>

以上这篇jQuery easyUI datagrid 增加求和统计行的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:深入理解Ajax的get和post请求
下一篇:JS小数运算出现多为小数问题的解决方法
易贤网手机网站地址:jQuery easyUI datagrid 增加求和统计行的实现代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!