Postingan lainnya
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
Hasil Subtotal tidak tampil
Hallo teman2 saya mau nanya nii, saya ada kendala saat export data, ketika di export data, hasil subtotal tidak ikut terexport. ini kenapa ya teman2?
table
image.pnghasil export
image.pngtable
<table border="1" id="example" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>NAMA PEGAWAI</th>
<th>TANGGAL</th>
<th>JAM</th>
<th>URAIAN TUGAS</th>
<th>WAKTU
</br>(menit)
</th>
<th>JUMLAH KEGIATAN</th>
<th>WAKTU EFEKTIVITAS</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody>
<?php
// $subtotal=0;
$ambildata = "SELECT * FROM tb_paru ORDER BY tanggal,nama_depan";
$sql = mysqli_query($conn, $ambildata) or die (mysqli_eror($conn));
while($data=mysqli_fetch_array($sql)){
$nama_depan = $data['nama_depan'];
$tanggal = $data['tanggal'];
$jam = $data['jam'];
$uraian_tugas = $data['uraian_tugas'];
$waktu = $data['waktu'];
$jumlah_capaian = $data['jumlah_capaian'];
$waktu_efektivitas = $data['waktu_efektivitas'];
$total = $data['total'];
// $subtotal+=$total/60;
?>
<tr>
<td><?=$nama_depan;?></td>
<td><?=$tanggal;?></td>
<td><?=$jam;?></td>
<td><?=$uraian_tugas;?></td>
<td><?=$waktu;?></td>
<td><?=$jumlah_capaian;?></td>
<td><?=$waktu_efektivitas;?></td>
<td><?=$total;?></td>
</tr>
<?php
};
?>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>SUBTOTAL</td>
<td><?php echo $subtotal ?></td>
<td></td>
</tr>
</tfoot>
<script>
$(document).ready(function () {
$('#example').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
footerCallback: function (row, data, start, end, display) {
var api = this.api();
var intVal = function (i) {
return typeof i === 'string'
? i.replace(/[\$,]/g, '') * 1
: typeof i === 'number'
? i
: 0;
};
total = api
.column(7)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
pageTotal = api
.column(7, {page: 'current'})
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
$(api.column(7).footer()).html(pageTotal / 60);
}
},);
});
</script>
1 Jawaban:
Jawaban Terpilih
<div>tambahin option</div><pre>footer: <strong>true</strong></pre><div>untuk tiap button.</div><div><br>(By default the data export buttons do not include the table footer (if present) in the output. That behaviour can be altered using the footer option that is present for each of the export buttons, as shown in this example.)<br><a href="https://datatables.net/extensions/buttons/examples/html5/footer.html"><br>https://datatables.net/extensions/buttons/examples/html5/footer.html</a></div>
Tanggapan
okeee sudaahh bg.. trimksi banyaaak bgg.. :D