 |
รบกวนหน่อยค่ะ พอดีอยากได้ code คำนวณแบบรวมผล จากที่เราค้นหา |
|
 |
|
|
 |
 |
|
Footer Callback ของ DataTables มีทั้งรวมต่อหน้าและรวมทั้งหมด
Code (JavaScript)
$(document).ready(function() {
$('#example').DataTable( {
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// Total over all pages
total = api
.column( 4 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column( 4, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 4 ).footer() ).html(
'$'+pageTotal +' ( $'+ total +' total)'
);
}
} );
} );
แต่จะให้ดีดูตัวอย่างที่นี้เลยดีกว่า https://datatables.net/examples/advanced_init/footer_callback.html
|
ประวัติการแก้ไข 2017-08-08 13:47:10
 |
 |
 |
 |
Date :
2017-08-08 13:45:52 |
By :
ccjpn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|