Display Specific Column Data in infoCallback
Display Specific Column Data in infoCallback

In custom formatting the infoCallback
, how do I go about getting a specific column's data? I can output all the rows and their data such as given in the example. I have a table with a column called "totaltime" that I want to display.
"infoCallback": function( settings, start, end, max, total, pre ) {
var api = new $.fn.dataTable.Api( settings );
console.log( api.rows( {page:'current'} ).data() );
return start + "–" + end + " of " + total + " tracks";
}
So, I want to return something like this:
- 1–10 of 54 tracks (35:15:03)
where the item in parenthesis represents my totaltime column.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The FooterCallback example shows how you can get the total of a specific column. The example is summing numbers. You will need to do something different to sum times. Maybe use moment.js for this or you might find suggestions on Stack Overflow.
Kevin
What I need is to be able to access a single column from the data attribute instead of this line:
which displays all of the data.
I want to only access the column called "totaltime" which is returned from the database.
This code snippet from the example I linked to will access the data in a particular column on the current page:
If you need help creating this then please build a simple test case with an example of your data. We can then help you with a solution.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Ok, so here's what I came up with and it does return a single value from a specific column, and I assume this is the best approach to take:
Sorry, I thought you were wanting to total the
totaltime
column. If that approach works for what you want then its a good oneKevin
No problem. You still helped me find the answer by the code snippet you gave as it put me on the course to find the answer I was looking for.