-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
footer line with totals. #136
Comments
there are many ways to do a 'total' and honestly its pretty user dependent.. as its a slippery slope if you do it for 'us numbers' then everyone will ask for it for x format.. tablesorter is already a little bloated as it is (somewhat due to legacy reasons). you obviously could do it easy enough just by extending the format command.. i see some pitfalls but overally it looks simple enough that others could use and modify for their own needs. also, what about pagination and updating the totals? :p |
I didn't try it with pagination, but it is called with all sorts and recalcs, as you probably already know due to way it is currently code, which is awesome, of course. I will try it out at some point. I figured if someone can use this to help them with their needs then I have help give back to the community, :). |
Hi mitcrellim! Thanks for sharing! I actually have a similar demo (which I just updated) that has subtotals, column totals and a grand total. It's a bit messy, but you can see that the code can get rather complicated. I'm not sure if there is a good method to make a column total widget work in all situations. To get your widget working with the pager plugin, make sure the pager plugin |
Thanks for sharing yours. It is very nice. I will post an update when I test this with the pager plugin. |
I don't know if you plan to add this, but I couldn't find a good example out there. So I wrote my own custom widget to do this. I will include it here for anyone to use/enhance, etc. Maybe it can become part of a future release? So consider this an enhancement request. I do not consider myself a javascript guru, but have the basics all down. and I am using this in one of my pages.
Setup:
Create a tfoot section to your table with the same columns as your header. Add a class with the name of sum for summing up the contents of the column. I expect I will add more in the future, such as count to count the number of rows, avg to calculate the average, etc. Not sure what else. tfoot example:
This is a 5 column table with totals in two of the columns. The code will replace all values with an empty string or the calculated total.
Here is the widget add on code:
I only have the sum function in there now as that is all I currently need. I can see a need for specifying the formatting of the total, too. And making sure it handles all number types.
I am open to improvements on this and would love to see this in the baseline some day, some kind of functionality like this at least.
The text was updated successfully, but these errors were encountered: