jQuery easyUI datagrid 增加求和統(tǒng)計行的實現(xiàn)代碼
來源:易賢網(wǎng) 閱讀:3247 次 日期:2016-06-17 11:56:59
溫馨提示:易賢網(wǎng)小編為您整理了“jQuery easyUI datagrid 增加求和統(tǒng)計行的實現(xiàn)代碼”,方便廣大網(wǎng)友查閱!

下面小編就為大家?guī)硪黄猨Query easyUI datagrid 增加求和統(tǒng)計行的實現(xiàn)代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。

在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 增加求和統(tǒng)計行的實現(xiàn)代碼就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考

更多信息請查看網(wǎng)絡編程

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)