Datatables Datepicker Dynamic CalculationsLINQ query on a DataTableHow can I merge properties of two JavaScript objects dynamically?Event binding on dynamically created elements?How to make datepicker appear on every row in table phpBootstrap datepicker changeDate regex errorUse DatePicker to filter DataTableCreating multiple datepickers by passing parametersHow to set value to datepicker jquery ui with php?Filtering HTML Table by DatePicker is between two dates

Why the car dealer is insisting on loan instead of cash

What organs or modifications would be needed for a life biological creature not to require sleep?

I am getting "syntax error near unexpected token `'$#''" in a simple Bash script

Specific filter on the set using Python

Bit one of the Intel 8080's Flags register

Consonance v. Dissonance

How do I say "quirky" in German without sounding derogatory?

What makes a smart phone "kosher"?

Speedometer as a symbol into awesomebox

Why does "arimasen" mean "there's no hope"?

What do the French say for “Oh, you shouldn’t have”?

Ambiguity in notation resolved by +

Telling my mother that I have anorexia without panicking her

Asked to Not Use Transactions and to Use A Workaround to Simulate One

Amortized Loans seem to benefit the bank more than the customer

If I want an interpretable model, are there methods other than Linear Regression?

simjacker: which SIMs are vulnerable?

Why is the year in this ISO timestamp not 2019?

What is the mathematical notation for rounding a given number to the nearest integer?

Why does the speed of sound decrease at high altitudes although the air density decreases?

Are there any “Third Order” acronyms used in space exploration?

How to publish superseding results without creating enemies

How are unbalanced coaxial cables used for broadcasting TV signals without any problems?

What next step can I take in solving this sudoku?



Datatables Datepicker Dynamic Calculations


LINQ query on a DataTableHow can I merge properties of two JavaScript objects dynamically?Event binding on dynamically created elements?How to make datepicker appear on every row in table phpBootstrap datepicker changeDate regex errorUse DatePicker to filter DataTableCreating multiple datepickers by passing parametersHow to set value to datepicker jquery ui with php?Filtering HTML Table by DatePicker is between two dates






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Using Datatables 1.10.19 and bootstrap-datepicker v1.8.0



I have two columns in my table, one contains a cash value, the other contains payment type (cash / card). What I need to do is calculate the totals for each payment type whenever the data is filtered via the datepicker.



So, when a date range is selected I need to display;




Total Cash: £x



Total Card £x




I'm already able to calculate the totals within the table, and when it's filtered via the search input, but i'm stuck on the datepicker.



I have created a fiddle here. Code is below;



html



<div class="container">
<div class="col-md-4 pull-right">
<div class="input-group input-daterange">
<input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="min-date" placeholder="From:" type="text">
<div class="input-group-addon">
to
</div><input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="max-date" placeholder="To:" type="text">
</div>
</div>
</div>
<hr>
<p>Overall Totals: <span id="overallTotals"></span></p>
<p>Filtered Totals: <span id="filteredTotals"></span></p>
<hr>
<table class="table table-striped table-bordered" id="records" style="width:100%">
<thead>
<tr>
<th>Date Paid</th>
<th>Invoice</th>
<th>Amount</th>
<th>Charge Type</th>
<th>Payment Type</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
<tbody>
<tr class="odd" role="row">
<td class="sorting_1">27-03-2019</td>
<td>521735</td>
<td>0.20</td>
<td>overdue</td>
<td>Card</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">27-03-2019</td>
<td>513938</td>
<td>1.20</td>
<td>overdue</td>
<td>Cash</td>
</tr>
<tr class="odd" role="row">
<td class="sorting_1">27-03-2019</td>
<td>523693</td>
<td>0.20</td>
<td>overdue</td>
<td>Cash</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">27-03-2019</td>
<td>493645</td>
<td>0.10</td>
<td>overdue renewed</td>
<td>Cash</td>
</tr>
<tr class="odd" role="row">
<td class="sorting_1">27-03-2019</td>
<td>521734</td>
<td>0.20</td>
<td>overdue</td>
<td>Card</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">27-03-2019</td>
<td>493646</td>
<td>0.10</td>
<td>overdue renewed</td>
<td>Cash</td>
</tr>
<tr class="odd" role="row">
<td class="sorting_1">27-03-2019</td>
<td>523691</td>
<td>0.10</td>
<td>overdue renewed</td>
<td>Card</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">27-03-2019</td>
<td>523692</td>
<td>0.10</td>
<td>overdue renewed</td>
<td>Card</td>
</tr>
<tr class="odd" role="row">
<td class="sorting_1">27-03-2019</td>
<td>523694</td>
<td>0.20</td>
<td>overdue</td>
<td>Cash</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">26-03-2019</td>
<td>506326</td>
<td>1.20</td>
<td>overdue</td>
<td>Card</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">26-03-2019</td>
<td>506322</td>
<td>1.60</td>
<td>overdue</td>
<td>Card</td>
</tr>
<tr class="even" role="row">
<td class="sorting_1">25-03-2019</td>
<td>506399</td>
<td>5.20</td>
<td>overdue</td>
<td>Card</td>
</tr>
</tbody>
</table>


js



$(document).ready(function() 
// Bootstrap datepicker
$('.input-daterange input').each(function()
$(this).datepicker('clearDates');
);
var table = $('#records').DataTable(
"order": [
[0, "desc"]
],
"columns": [
data: 'datePaid',
,
data: 'invoice',
,
data: 'amount',
"render": function(data, type, row)
return '£' + Number(data).toFixed(2);
,
,
data: 'chargeType'
,
data: 'paymentType'
, ],
"columnDefs": [
targets: [0],
type: 'date-eu'
],
"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;
;
// find column named Amount
var costColumnIndex = $('th').filter(function(i)
return $(this).text() == 'Amount';
).first().index();
// array of total column values
var totalData = api.column(costColumnIndex).data();
// total of column values
var total = totalData.reduce(function(a, b)
return intVal(a) + intVal(b);
, 0).toFixed(2);
// array of displayed column values
var pageTotalData = api.column(costColumnIndex,
page: 'current'
).data();
// total of displayed values
var pageTotal = pageTotalData.reduce(function(a, b)
return intVal(a) + intVal(b);
, 0).toFixed(2);
// array of displayed column values
var searchTotalData = api.column(costColumnIndex,
'filter': 'applied'
).data();
// total of displayed values
var searchTotal = searchTotalData.reduce(function(a, b)
return intVal(a) + intVal(b);
, 0).toFixed(2);
// console.log(searchTotal);
$('#overallTotals').html('Approximate page total £' + pageTotal + ', search total £' + searchTotal + ', totally total $' + total);
$('#filteredTotals').html('Cash total £' + 'x' + ', Card total £' + 'x');
$(api.column(2).footer()).html('£' + Number(pageTotal).toFixed(2));
,
);
// Extend dataTables search
$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) (moment(createdAt).isSameOrAfter(min) && moment(createdAt).isSameOrBefore(max)))
return true;

return false;
);
// Re-draw the table when the a date range filter changes
$('.date-range-filter').change(function()
$('#records').DataTable().draw();
);
);


Any help is appreciated.










share|improve this question






























    1















    Using Datatables 1.10.19 and bootstrap-datepicker v1.8.0



    I have two columns in my table, one contains a cash value, the other contains payment type (cash / card). What I need to do is calculate the totals for each payment type whenever the data is filtered via the datepicker.



    So, when a date range is selected I need to display;




    Total Cash: £x



    Total Card £x




    I'm already able to calculate the totals within the table, and when it's filtered via the search input, but i'm stuck on the datepicker.



    I have created a fiddle here. Code is below;



    html



    <div class="container">
    <div class="col-md-4 pull-right">
    <div class="input-group input-daterange">
    <input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="min-date" placeholder="From:" type="text">
    <div class="input-group-addon">
    to
    </div><input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="max-date" placeholder="To:" type="text">
    </div>
    </div>
    </div>
    <hr>
    <p>Overall Totals: <span id="overallTotals"></span></p>
    <p>Filtered Totals: <span id="filteredTotals"></span></p>
    <hr>
    <table class="table table-striped table-bordered" id="records" style="width:100%">
    <thead>
    <tr>
    <th>Date Paid</th>
    <th>Invoice</th>
    <th>Amount</th>
    <th>Charge Type</th>
    <th>Payment Type</th>
    </tr>
    </thead>
    <tfoot>
    <tr>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    <th></th>
    </tr>
    </tfoot>
    <tbody>
    <tr class="odd" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>521735</td>
    <td>0.20</td>
    <td>overdue</td>
    <td>Card</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>513938</td>
    <td>1.20</td>
    <td>overdue</td>
    <td>Cash</td>
    </tr>
    <tr class="odd" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>523693</td>
    <td>0.20</td>
    <td>overdue</td>
    <td>Cash</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>493645</td>
    <td>0.10</td>
    <td>overdue renewed</td>
    <td>Cash</td>
    </tr>
    <tr class="odd" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>521734</td>
    <td>0.20</td>
    <td>overdue</td>
    <td>Card</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>493646</td>
    <td>0.10</td>
    <td>overdue renewed</td>
    <td>Cash</td>
    </tr>
    <tr class="odd" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>523691</td>
    <td>0.10</td>
    <td>overdue renewed</td>
    <td>Card</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>523692</td>
    <td>0.10</td>
    <td>overdue renewed</td>
    <td>Card</td>
    </tr>
    <tr class="odd" role="row">
    <td class="sorting_1">27-03-2019</td>
    <td>523694</td>
    <td>0.20</td>
    <td>overdue</td>
    <td>Cash</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">26-03-2019</td>
    <td>506326</td>
    <td>1.20</td>
    <td>overdue</td>
    <td>Card</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">26-03-2019</td>
    <td>506322</td>
    <td>1.60</td>
    <td>overdue</td>
    <td>Card</td>
    </tr>
    <tr class="even" role="row">
    <td class="sorting_1">25-03-2019</td>
    <td>506399</td>
    <td>5.20</td>
    <td>overdue</td>
    <td>Card</td>
    </tr>
    </tbody>
    </table>


    js



    $(document).ready(function() 
    // Bootstrap datepicker
    $('.input-daterange input').each(function()
    $(this).datepicker('clearDates');
    );
    var table = $('#records').DataTable(
    "order": [
    [0, "desc"]
    ],
    "columns": [
    data: 'datePaid',
    ,
    data: 'invoice',
    ,
    data: 'amount',
    "render": function(data, type, row)
    return '£' + Number(data).toFixed(2);
    ,
    ,
    data: 'chargeType'
    ,
    data: 'paymentType'
    , ],
    "columnDefs": [
    targets: [0],
    type: 'date-eu'
    ],
    "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;
    ;
    // find column named Amount
    var costColumnIndex = $('th').filter(function(i)
    return $(this).text() == 'Amount';
    ).first().index();
    // array of total column values
    var totalData = api.column(costColumnIndex).data();
    // total of column values
    var total = totalData.reduce(function(a, b)
    return intVal(a) + intVal(b);
    , 0).toFixed(2);
    // array of displayed column values
    var pageTotalData = api.column(costColumnIndex,
    page: 'current'
    ).data();
    // total of displayed values
    var pageTotal = pageTotalData.reduce(function(a, b)
    return intVal(a) + intVal(b);
    , 0).toFixed(2);
    // array of displayed column values
    var searchTotalData = api.column(costColumnIndex,
    'filter': 'applied'
    ).data();
    // total of displayed values
    var searchTotal = searchTotalData.reduce(function(a, b)
    return intVal(a) + intVal(b);
    , 0).toFixed(2);
    // console.log(searchTotal);
    $('#overallTotals').html('Approximate page total £' + pageTotal + ', search total £' + searchTotal + ', totally total $' + total);
    $('#filteredTotals').html('Cash total £' + 'x' + ', Card total £' + 'x');
    $(api.column(2).footer()).html('£' + Number(pageTotal).toFixed(2));
    ,
    );
    // Extend dataTables search
    $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) (moment(createdAt).isSameOrAfter(min) && moment(createdAt).isSameOrBefore(max)))
    return true;

    return false;
    );
    // Re-draw the table when the a date range filter changes
    $('.date-range-filter').change(function()
    $('#records').DataTable().draw();
    );
    );


    Any help is appreciated.










    share|improve this question


























      1












      1








      1








      Using Datatables 1.10.19 and bootstrap-datepicker v1.8.0



      I have two columns in my table, one contains a cash value, the other contains payment type (cash / card). What I need to do is calculate the totals for each payment type whenever the data is filtered via the datepicker.



      So, when a date range is selected I need to display;




      Total Cash: £x



      Total Card £x




      I'm already able to calculate the totals within the table, and when it's filtered via the search input, but i'm stuck on the datepicker.



      I have created a fiddle here. Code is below;



      html



      <div class="container">
      <div class="col-md-4 pull-right">
      <div class="input-group input-daterange">
      <input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="min-date" placeholder="From:" type="text">
      <div class="input-group-addon">
      to
      </div><input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="max-date" placeholder="To:" type="text">
      </div>
      </div>
      </div>
      <hr>
      <p>Overall Totals: <span id="overallTotals"></span></p>
      <p>Filtered Totals: <span id="filteredTotals"></span></p>
      <hr>
      <table class="table table-striped table-bordered" id="records" style="width:100%">
      <thead>
      <tr>
      <th>Date Paid</th>
      <th>Invoice</th>
      <th>Amount</th>
      <th>Charge Type</th>
      <th>Payment Type</th>
      </tr>
      </thead>
      <tfoot>
      <tr>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      </tr>
      </tfoot>
      <tbody>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>521735</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>513938</td>
      <td>1.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523693</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>493645</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>521734</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>493646</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523691</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523692</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Card</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523694</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">26-03-2019</td>
      <td>506326</td>
      <td>1.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">26-03-2019</td>
      <td>506322</td>
      <td>1.60</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">25-03-2019</td>
      <td>506399</td>
      <td>5.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      </tbody>
      </table>


      js



      $(document).ready(function() 
      // Bootstrap datepicker
      $('.input-daterange input').each(function()
      $(this).datepicker('clearDates');
      );
      var table = $('#records').DataTable(
      "order": [
      [0, "desc"]
      ],
      "columns": [
      data: 'datePaid',
      ,
      data: 'invoice',
      ,
      data: 'amount',
      "render": function(data, type, row)
      return '£' + Number(data).toFixed(2);
      ,
      ,
      data: 'chargeType'
      ,
      data: 'paymentType'
      , ],
      "columnDefs": [
      targets: [0],
      type: 'date-eu'
      ],
      "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;
      ;
      // find column named Amount
      var costColumnIndex = $('th').filter(function(i)
      return $(this).text() == 'Amount';
      ).first().index();
      // array of total column values
      var totalData = api.column(costColumnIndex).data();
      // total of column values
      var total = totalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // array of displayed column values
      var pageTotalData = api.column(costColumnIndex,
      page: 'current'
      ).data();
      // total of displayed values
      var pageTotal = pageTotalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // array of displayed column values
      var searchTotalData = api.column(costColumnIndex,
      'filter': 'applied'
      ).data();
      // total of displayed values
      var searchTotal = searchTotalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // console.log(searchTotal);
      $('#overallTotals').html('Approximate page total £' + pageTotal + ', search total £' + searchTotal + ', totally total $' + total);
      $('#filteredTotals').html('Cash total £' + 'x' + ', Card total £' + 'x');
      $(api.column(2).footer()).html('£' + Number(pageTotal).toFixed(2));
      ,
      );
      // Extend dataTables search
      $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) (moment(createdAt).isSameOrAfter(min) && moment(createdAt).isSameOrBefore(max)))
      return true;

      return false;
      );
      // Re-draw the table when the a date range filter changes
      $('.date-range-filter').change(function()
      $('#records').DataTable().draw();
      );
      );


      Any help is appreciated.










      share|improve this question














      Using Datatables 1.10.19 and bootstrap-datepicker v1.8.0



      I have two columns in my table, one contains a cash value, the other contains payment type (cash / card). What I need to do is calculate the totals for each payment type whenever the data is filtered via the datepicker.



      So, when a date range is selected I need to display;




      Total Cash: £x



      Total Card £x




      I'm already able to calculate the totals within the table, and when it's filtered via the search input, but i'm stuck on the datepicker.



      I have created a fiddle here. Code is below;



      html



      <div class="container">
      <div class="col-md-4 pull-right">
      <div class="input-group input-daterange">
      <input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="min-date" placeholder="From:" type="text">
      <div class="input-group-addon">
      to
      </div><input class="form-control date-range-filter" data-date-format="dd-mm-yyyy" id="max-date" placeholder="To:" type="text">
      </div>
      </div>
      </div>
      <hr>
      <p>Overall Totals: <span id="overallTotals"></span></p>
      <p>Filtered Totals: <span id="filteredTotals"></span></p>
      <hr>
      <table class="table table-striped table-bordered" id="records" style="width:100%">
      <thead>
      <tr>
      <th>Date Paid</th>
      <th>Invoice</th>
      <th>Amount</th>
      <th>Charge Type</th>
      <th>Payment Type</th>
      </tr>
      </thead>
      <tfoot>
      <tr>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      </tr>
      </tfoot>
      <tbody>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>521735</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>513938</td>
      <td>1.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523693</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>493645</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>521734</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>493646</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Cash</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523691</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523692</td>
      <td>0.10</td>
      <td>overdue renewed</td>
      <td>Card</td>
      </tr>
      <tr class="odd" role="row">
      <td class="sorting_1">27-03-2019</td>
      <td>523694</td>
      <td>0.20</td>
      <td>overdue</td>
      <td>Cash</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">26-03-2019</td>
      <td>506326</td>
      <td>1.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">26-03-2019</td>
      <td>506322</td>
      <td>1.60</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      <tr class="even" role="row">
      <td class="sorting_1">25-03-2019</td>
      <td>506399</td>
      <td>5.20</td>
      <td>overdue</td>
      <td>Card</td>
      </tr>
      </tbody>
      </table>


      js



      $(document).ready(function() 
      // Bootstrap datepicker
      $('.input-daterange input').each(function()
      $(this).datepicker('clearDates');
      );
      var table = $('#records').DataTable(
      "order": [
      [0, "desc"]
      ],
      "columns": [
      data: 'datePaid',
      ,
      data: 'invoice',
      ,
      data: 'amount',
      "render": function(data, type, row)
      return '£' + Number(data).toFixed(2);
      ,
      ,
      data: 'chargeType'
      ,
      data: 'paymentType'
      , ],
      "columnDefs": [
      targets: [0],
      type: 'date-eu'
      ],
      "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;
      ;
      // find column named Amount
      var costColumnIndex = $('th').filter(function(i)
      return $(this).text() == 'Amount';
      ).first().index();
      // array of total column values
      var totalData = api.column(costColumnIndex).data();
      // total of column values
      var total = totalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // array of displayed column values
      var pageTotalData = api.column(costColumnIndex,
      page: 'current'
      ).data();
      // total of displayed values
      var pageTotal = pageTotalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // array of displayed column values
      var searchTotalData = api.column(costColumnIndex,
      'filter': 'applied'
      ).data();
      // total of displayed values
      var searchTotal = searchTotalData.reduce(function(a, b)
      return intVal(a) + intVal(b);
      , 0).toFixed(2);
      // console.log(searchTotal);
      $('#overallTotals').html('Approximate page total £' + pageTotal + ', search total £' + searchTotal + ', totally total $' + total);
      $('#filteredTotals').html('Cash total £' + 'x' + ', Card total £' + 'x');
      $(api.column(2).footer()).html('£' + Number(pageTotal).toFixed(2));
      ,
      );
      // Extend dataTables search
      $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) (moment(createdAt).isSameOrAfter(min) && moment(createdAt).isSameOrBefore(max)))
      return true;

      return false;
      );
      // Re-draw the table when the a date range filter changes
      $('.date-range-filter').change(function()
      $('#records').DataTable().draw();
      );
      );


      Any help is appreciated.







      javascript jquery datatable datepicker calculated-columns






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 10:54









      TheOrdinaryGeekTheOrdinaryGeek

      1,0357 silver badges22 bronze badges




      1,0357 silver badges22 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395812%2fdatatables-datepicker-dynamic-calculations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55395812%2fdatatables-datepicker-dynamic-calculations%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?