From 46c58848530ee5268a54cdb6232f19d3d630e4d3 Mon Sep 17 00:00:00 2001
From: Allan Jardine
Date: Tue, 12 Nov 2013 19:18:29 +0000
Subject: [PATCH] Examples: Update footer callback with use of
column().footer()
---
.datatables-commit-sync | 2 +-
examples/advanced_init/footer_callback.html | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/.datatables-commit-sync b/.datatables-commit-sync
index cd39e722..47a0e0ec 100644
--- a/.datatables-commit-sync
+++ b/.datatables-commit-sync
@@ -1 +1 @@
-319a8babbafdd3a87242271126086806252542c3
+d8c274637a604327bc05c32593b6199b4080e9b9
diff --git a/examples/advanced_init/footer_callback.html b/examples/advanced_init/footer_callback.html
index da593ecd..3db8f03b 100644
--- a/examples/advanced_init/footer_callback.html
+++ b/examples/advanced_init/footer_callback.html
@@ -24,6 +24,7 @@ $(document).ready(function() {
$('#example').dataTable( {
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api();
+ // Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
@@ -48,7 +49,7 @@ $(document).ready(function() {
} );
// Update footer
- $('th:eq(1)', row).html(
+ $( api.column( 4 ).footer() ).html(
'$'+pageTotal +' ( $'+ total +' total)'
);
}
@@ -73,7 +74,11 @@ $(document).ready(function() {
data manipulation functions, such as summarising data in the table.
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.
+ visible and the hidden data) using the column().data()
API method and column().footer()
for writing the value into the footer.
@@ -512,6 +517,7 @@ $(document).ready(function() {
$('#example').dataTable( {
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api();
+ // Remove the formatting to get integer data for summation
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
@@ -536,7 +542,7 @@ $(document).ready(function() {
} );
// Update footer
- $('th:eq(1)', row).html(
+ $( api.column( 4 ).footer() ).html(
'$'+pageTotal +' ( $'+ total +' total)'
);
}