Sum colum in serverSide (all records)

Sum colum in serverSide (all records)

andrewtegandrewteg Posts: 3Questions: 1Answers: 0

I'm basically doing the same thing at https://datatables.net/forums/discussion/49522/sum-colum-in-serverside-all-records where @kthorngren solved it with an example that is now 404.

I'm not sure how to actually update the footer row in the drawCallback with a server side variable.

I have setup my footer with a <tfoot> code and columns like:
<th class="bg-secondary text-white" id="miles_total">TEST1</th>

In drawCallback I can see the "TEST1" as the first console and the value I want as the second:
console.log($('#miles_total div').html()) console.log(response.json.totals.miles)

I've tried various versions of this jQuery to set it with no success:
$('#miles_total div').text(response.json.totals.miles)

How can I set the tfoot value in drawCallback?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited November 2022 Answer ✓

    The example still works. Your browser may be changing http:// to https://. Edit the URL, in your browser, to remove the s from https://. For example: http://live.datatables.net/sagujiza/1/edit.

    The selector $('#miles_total div') doesn't seem right. Try this instead without the div:

    $('#miles_total').text(response.json.totals.miles)
    

    Kevin

  • andrewtegandrewteg Posts: 3Questions: 1Answers: 0
    edited November 2022

    Thanks. I'd tried without the div but that hadn't worked either so I ended up getting to the example and found it worked calling it by column:

    var api = this.api();
    $(api.column(1).footer()).html('Total:');
    $(api.column(5).footer()).html(response.json.totals.miles);
    
Sign In or Register to comment.