Hi,
how can I add to the footer of the table some kinds of totals (as Sum, Average, Count, etc)?
Always Thanks in advance
At the moment tabulator will only generate a footer element when pagination is enabled, though the ability to add a footer at any point will be coming soon.
In the mean time i would suggest you create a relatively positioned element that sits below the table.
When data is successfully loaded into the table the _dataLoaded_ callback is triggered, passing the parsed data as an argument, you could then run your calculations on this data and update the contents of your footer element.
$("#example-table").tabulator({
dataLoaded:function(data){
//data - the data for the row
//process your data here
},
});
for more information see the documentation for full details.
Just in case this would be of use to you, there is now a _dataFiltered_ callback that is called any time the filtered data set is changed, which will give you more accurate totals for your sum, average and count functions.
for more information see the documentation for full details.
Hey,
You will be happy to hear that Tabulator 3.2 has just been released, and with it the Column Calculations system:
{title:"Cost", field:"cost", bottomCalc:"avg"} //show average cost in bottom calculation row
Full information can be found in the Calculations Documentation
Cheers
Oli
Hello @olifolkerd
I am currently looking to do total bars, but I don't want tabulator to calculate it because I want ajax to pull only desired items based on the page, which means I will need to run a separate total array of data in php. Is there a way to accomplish this? basically having totals be appended to the output of the ajax response and added to the table footer columns? even if I have to custom code something, are you able to send me in the right direction?
Hey @timothymarois
Thanks for getting in touch,
This is really a separate issue so i would ask that in future you ask your question on stack overflow to avoid confusing old issues.
In answer to your question i would suggest that you use Custom Calculation Functions in your column calculations, they could pull the data from another array instead of the row data.
I hope that helps,
Cheers
Oli :)
Most helpful comment
Hey,
You will be happy to hear that Tabulator 3.2 has just been released, and with it the Column Calculations system:
Full information can be found in the Calculations Documentation
Cheers
Oli