我想在链接https://datatables.net/extensions/rowgroup/examples/initialisation/customRow.html中应用该方法
我的代码:
dt2 = $("#beyanname2Table").DataTable(
{
dom: 'Bfrtip',
buttons: ['excel', 'print'],
lengthChange: false,
searching: false,
paging: false,
order: [[1, 'asc']],
rowGroup: {
startRender: null,
endRender: function (rows, group) {
var salaryAvg = rows
.data()
.pluck(4)
.reduce(function (a, b) {
return a + b.replace(/[^\d]/g, '') * 1;
}, 0);
salaryAvg = $.fn.dataTable.render.number(',', '.',
0, '$').display(salaryAvg);
return $('<tr/>')
.append('<td colspan="3">Averages for ' + group
+ '</td>')
.append('<td/>')
.append('<td>' + salaryAvg + '</td>');
},
dataSrc: 1
},
"ajax": {
"url": "/Müsavir/Musavir_RaporlamaSonuc",
"type": "GET",
"datatype": "json",
},
"columns": [
{ "data": "Urun_SatirKod" },
{ "data": "Urun_Gtip" },
{ "data": "Urun_MaddeAd" },
{ "data": "Oran" },
{ "data": "Adet" },
{ "data": "GBC_No" },
{ "data": "GBC_Tarih" },
{ "data": "UrunGumruk" },
{ "data": "Com_SatirKod" },
{ "data": "Com_Gtip" },
{ "data": "Com_Adi" },
{ "data": "Miktar" },
{ "data": "Deger" },
{ "data": "GB_No" },
{ "data": "GB_Tarih" },
{ "data": "Gumruk" },
{ "data": "IthalVergiOran" },
{ "data": "OdenecekTEV" },
{ "data": "IhracKur" },
{ "data": "OdenenTEV" },
{ "data": "Anapara" },
{ "data": "Faiz" },
{ "data": "Fark" }
],
});
表格视图如图所示。我想建立一个基于“ Urun_Gtip”的组,并获得“ Adet”的总本金值。