1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-27 00:54:15 +01:00

Update example: Use an initial value for the dt-api reduce() call to simplify the logic

This commit is contained in:
Allan Jardine 2014-11-03 15:17:30 +00:00
parent e92582b45a
commit f8770a6b2a
2 changed files with 25 additions and 25 deletions

View File

@ -1 +1 @@
eaab86e69bff4097fc40e67eab5be8a62aeb1c0f
2c6998e1a55bea1310655664b363dbc886208c9c

View File

@ -35,20 +35,20 @@ $(document).ready(function() {
};
// Total over all pages
data = api.column( 4 ).data();
total = data.length ?
data.reduce( function (a, b) {
return intVal(a) + intVal(b);
} ) :
0;
total = api
.column( 4 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
} );
// Total over this page
data = api.column( 4, { page: 'current'} ).data();
pageTotal = data.length ?
data.reduce( function (a, b) {
return intVal(a) + intVal(b);
} ) :
0;
pageTotal = api
.column( 4, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 4 ).footer() ).html(
@ -530,20 +530,20 @@ $(document).ready(function() {
};
// Total over all pages
data = api.column( 4 ).data();
total = data.length ?
data.reduce( function (a, b) {
return intVal(a) + intVal(b);
} ) :
0;
total = api
.column( 4 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
} );
// Total over this page
data = api.column( 4, { page: 'current'} ).data();
pageTotal = data.length ?
data.reduce( function (a, b) {
return intVal(a) + intVal(b);
} ) :
0;
pageTotal = api
.column( 4, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 4 ).footer() ).html(