jquery表格插件DataTables 合计功能(当前页)

[email protected]

1.table中添加

<tfoot>
  <tr>
  <td><b>当前页合计</b>
   </td>
   <td id="weightsum">                                                
   </td>
    <td>
  </tr>
</tfoot>

2.js

var addd=0;
$(document).ready(function() {
	$('#table1').dataTable({
          "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
             if(iDisplayIndex==0) addd=0;
               addd+=parseFloat(aData[1]);//第几列
               $("#weightsum").html(formatFloat(addd,3));
               return nRow;
             } 
           }
        );
} );


你可能感兴趣的:(function,datatables,jquery表格插件)