我正在尝试对数据表中的数据进行分组,但这很好,但是我需要计算每组总数占总数的百分比。 谢谢你的建议
$('#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) {
}
});