Sum the data of one column but filter by slected rows
Sum the data of one column but filter by slected rows
sparh
Posts: 11Questions: 2Answers: 0
Hi,
i would like to Sum the data of one column but filter by slected rows (https://datatables.net/extensions/select/)
I use this code to get the total of one column and It is working fine:
pageTotal = api
.column( 3, { page: 'all'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 3 ).footer() ).html(
formatCurrency(pageTotal)
);
But nowI would like to get the total of the 3rd column but only selected rows
I have tried this without any success
pageTotal = api
.rows({ selected: true })
.column( 3, { page: 'all'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
$( api.column( 3 ).footer() ).html(
formatCurrency(pageTotal)
);
Can you help me with this ?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You would need to do something like:
Allan
Thank you Allan