mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-07 05:54:15 +01:00
Examples: Update footer callback with use of column().footer()
This commit is contained in:
parent
c8d2ebedc1
commit
46c5884853
@ -1 +1 @@
|
|||||||
319a8babbafdd3a87242271126086806252542c3
|
d8c274637a604327bc05c32593b6199b4080e9b9
|
||||||
|
@ -24,6 +24,7 @@ $(document).ready(function() {
|
|||||||
$('#example').dataTable( {
|
$('#example').dataTable( {
|
||||||
"footerCallback": function ( row, data, start, end, display ) {
|
"footerCallback": function ( row, data, start, end, display ) {
|
||||||
var api = this.api();
|
var api = this.api();
|
||||||
|
// Remove the formatting to get integer data for summation
|
||||||
var intVal = function ( i ) {
|
var intVal = function ( i ) {
|
||||||
return typeof i === 'string' ?
|
return typeof i === 'string' ?
|
||||||
i.replace(/[\$,]/g, '')*1 :
|
i.replace(/[\$,]/g, '')*1 :
|
||||||
@ -48,7 +49,7 @@ $(document).ready(function() {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// Update footer
|
// Update footer
|
||||||
$('th:eq(1)', row).html(
|
$( api.column( 4 ).footer() ).html(
|
||||||
'$'+pageTotal +' ( $'+ total +' total)'
|
'$'+pageTotal +' ( $'+ total +' total)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -73,7 +74,11 @@ $(document).ready(function() {
|
|||||||
data manipulation functions, such as summarising data in the table.</p>
|
data manipulation functions, such as summarising data in the table.</p>
|
||||||
|
|
||||||
<p>The example below shows a footer callback being used to total the data for a column (both the
|
<p>The example below shows a footer callback being used to total the data for a column (both the
|
||||||
visible and the hidden data) using the `dt-api column().data() API method.</p>
|
visible and the hidden data) using the <a href=
|
||||||
|
"//datatables.net/api/column%28%29.data%28%29"><code class="api" title=
|
||||||
|
"API method">column().data()</code></a> API method and <a href=
|
||||||
|
"//datatables.net/api/column%28%29.footer%28%29"><code class="api" title=
|
||||||
|
"API method">column().footer()</code></a> for writing the value into the footer.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table id="example" class="display" cellspacing="0" width="100%">
|
<table id="example" class="display" cellspacing="0" width="100%">
|
||||||
@ -512,6 +517,7 @@ $(document).ready(function() {
|
|||||||
$('#example').dataTable( {
|
$('#example').dataTable( {
|
||||||
"footerCallback": function ( row, data, start, end, display ) {
|
"footerCallback": function ( row, data, start, end, display ) {
|
||||||
var api = this.api();
|
var api = this.api();
|
||||||
|
// Remove the formatting to get integer data for summation
|
||||||
var intVal = function ( i ) {
|
var intVal = function ( i ) {
|
||||||
return typeof i === 'string' ?
|
return typeof i === 'string' ?
|
||||||
i.replace(/[\$,]/g, '')*1 :
|
i.replace(/[\$,]/g, '')*1 :
|
||||||
@ -536,7 +542,7 @@ $(document).ready(function() {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
// Update footer
|
// Update footer
|
||||||
$('th:eq(1)', row).html(
|
$( api.column( 4 ).footer() ).html(
|
||||||
'$'+pageTotal +' ( $'+ total +' total)'
|
'$'+pageTotal +' ( $'+ total +' total)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user