当前位置: 首页 > 新闻动态 > 软件编程

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

作者:用户投稿 浏览: 发布日期:2026-01-17
[导读]:下面小编就为大家带来一篇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 增加求和统计行的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

免责声明:转载请注明出处:http://m.jing-feng.com.cn/news/555148.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!