How to get sums of a num and values using data from 2 columns
How to get sums of a num and values using data from 2 columns
mmarzs
Posts: 12Questions: 4Answers: 0
I currently use a function that gets the counts of values in a search applied table however I'd like to use data from a different column as the num value in this function. What is the best way to pull that data in?
I'd like the num value to be the corresponding row data from the column 'points-earned:name'
var counts = {};
var num = 1
chartTableData.column('constituent-type:name', { search: 'applied' })
.data()
.each(function (val) {
if (counts[val]) {
counts[val] += num;
} else {
counts[val] = num;
}
});
Answers
is this what you mean?
https://datatables.net/forums/discussion/63404/footer-total-using-two-columns#latest
@montoyam No not exactly.
Using that example (http://live.datatables.net/yewikige/6/edit) it would be if I was trying to return the total ages by office, not just one office.
One option is to use
columns().data()
chainingtoArray()
to get the data into two arrays (within an array). Then use a loop to access each element in the array for your calculation. See if this example gets you started:http://live.datatables.net/popacuwa/1/edit
Kevin