.subtotal { font-weight: bold; }/*合计单元格样式*/

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 增加求和统计行的实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持积木网。

jQuery实现图片轮播效果代码(基于jquery.pack.js插件)
本文实例讲述了jQuery实现图片轮播效果代码。分享给大家供大家参考,具体如下:!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtm

jQuery获取单击节点对象的方法
本文实例讲述了jQuery获取单击节点对象的方法。分享给大家供大家参考,具体如下:event.target属性:scriptlanguage="JavaScript"type="text/javascript"$("document").ready

深入理解jQuery事件绑定
html:ahref="#"onclick="addBtn()"addBtn/adivid="mDiv"buttonclass="cBtn"onclick="alert(11111)"button1/buttonbuttonclass="cBtn"button2/buttonbuttonclass="cBtn"button3/button/divjavascript:scripttype="tex