Sum of numbers in column that updates when a filter is applied
Sum of numbers in column that updates when a filter is applied
Hi all,
I have a datatable with some filters on top, and a column with numbers, showing the total in the footer. The data comes from a WordPress-like CMS (Boltcms.io) as a normal <table>
and currently the total is calculated in twig/php.
When a visitor applies a filter, and only selected rows are shown, I would like to update the total so only the numbers in the selected/shown rows are counted in the sum. But how?
I am pretty sure that something like this is possible with DataTables, but I cannot seem to find it in the docs or this forum, so I am probably using the wrong search terms.
Thanks in advance for your help - or a link to the right page in the docs.
Answers
Not sure about how this works.
The FooterCallback example shows how to use Datatables to sum the columns.
Kevin
I think that is what I'm looking for, I'll give it a spin and keep you posted. Thanks a lot!
Update: I have got it working, and added some extras: reformatting the number and only showing the sum when a filter is active. I may come back here with another question about filters, but thanks so far.