jQuery Datatable组小计和百分比值在行中

时间:2019-04-09 11:05:26

标签: jquery datatables-1.10

我正在尝试对数据表中的数据进行分组,但这很好,但是我需要计算每组总数占总数的百分比。 谢谢你的建议

$('#tbl3').html('<table cellpadding="0" cellspacing="0" border="0" class="table table-hover table-striped" id="tblreltmpps3" width="100%"><tfoot><td class="center"></td><td class="center"></td><td class="center"></td><td class="center"></td></tfoot></table>');
tblreltmpps2 = $('#tblreltmpps3').DataTable({
    sAjaxSource: '',
    aoColumns: [
        {"sTitle": "Nome", "sClass": "center", "mData": "nomeUsuario"},
        {"sTitle": "Status", "sClass": "center", "mData": "nm_status"},
        {"sTitle": "Qtde", "sClass": "center", "mData": "qtd"},
        {"sTitle": "%", "sClass": "center", "mData": null}

    ],
        orderFixed: [[0, 'desc']],
        rowGroup: {
            dataSrc: 'nomeUsuario',
            startRender: null,
            endRender: function (rows, group) {
            var totalQtd = rows.data().pluck('qtd').reduce( function (a, b) {
                       return a + b*1;
            }, 0);

                return $('<tr/>')
                    .append( '<td colspan=2>Total :</td>' )
                    .append( '<td>'+totalQtd+'</td>' );

           }
        },
        rowCallback: function(row,data,dataIndex) {
   }   
});

current datatable image

0 个答案:

没有答案
相关问题