Can I use sum() api without jQuery?

Can I use sum() api without jQuery?

ZubyZuby Posts: 14Questions: 4Answers: 0

I'm instantiating the table like this and trying to use the sum api like this.

import DataTable from "datatables.net";
import 'datatables.net-plugins/api/sum().mjs';

const table = new DataTable('#jobsTable', {
serverSide: true,
ajax: '/jobs/load',
orderMulti: false,
language: {
searchPlaceholder:"Date? eg '2023-12-31'"
},
drawCallback: function () {
var api = this.api()
$( api.table().footer() ).html(
api.column( 4, {page:'current'} ).data().sum()
)
},
columns: [
// column data
]

can I use the sum api without jQuery? If it's possible then how?

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Sure, the column().footer() method just returns a cell element, so you can use:

    let col = api.column(4, {page:'current'});
    
    col.footer().textContent = col.data().sum();
    

    Allan

Sign In or Register to comment.