How to use sum.js to sum column values after column().search is applied.

How to use sum.js to sum column values after column().search is applied.

rdmrdm Posts: 178Questions: 47Answers: 4

I found the link to sum.js. While I found it is correctly giving me the sum of all records in a desired column, I am unable to get the sum of only selected records when applying a column search like this. I do not see this scenario in the code examples. What can I do to achieve the desired outcome?

// Initially, the summary table has a total of 957.
// ** 
// This search command returns the correct set of records
summaryTable.column(1).search(`^${selectedCampusFilter}$`,true).draw;

// This always returns 957 instead of the correct value after applying the search -- 12.
const counts = summaryTable.column(4).data().sum(); 
console.log(counts);

Answers

Sign In or Register to comment.