Subtotals in a new row

Subtotals in a new row

ursasmarursasmar Posts: 6Questions: 0Answers: 0
edited November 2012 in DataTables 1.9
I have the following test case up, http://live.datatables.net/usabel

I have added a grouping type function on the Engine column, and a total of Version that I add to the footer of the table. What I would Like to add is a new row, before the group change, that contains the subtotal of the group. The numbers I would like summed up are the version numbers.

Replies

  • codemonkcodemonk Posts: 24Questions: 0Answers: 0
    edited December 2012
    This may not help you depending on how you are building your table, but you be able to use some elements from it.

    The function i am talking about is fnGetData . You might be able to iterate over your rows and then try to insert where you have detected a change.
  • ursasmarursasmar Posts: 6Questions: 0Answers: 0
    That did the trick. I just loop through the fnGetData after the table is rendered and do all the subtotaling myself.
  • jasonalecjasonalec Posts: 3Questions: 0Answers: 0
    Hello, would it be possible to get a sample code with your subtotals? I have been able to get the groups to work and grand total but am unsure of the syntax to add more.

    Would also love to get some ideas about doing multiple groupings (ie on 2 columns) if you have anything. Thanks!!
  • MikeSMikeS Posts: 113Questions: 1Answers: 0
    Hello ursasmar,

    As was requested above by jasonalec, would you be willing to share your solution with the community? I believe that subtotals is a very common requirement when grouping data and if you have something that can ease the pain of "re-inventing the wheel" that would be fantastic.

    Another question for you, did you ever see the row grouping plugin for datatables (found here, http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/collapsibleGroups.html)? It allows you expand/collapse the grouped rows. Unfortunately, it didn't allow for subtotals of columns (although it could provide a subtotal of the number of rows per group). It would be even more fantastic if you could somehow put your subtotaling code into the row grouping plugin and "kill several birds with one stone"
This discussion has been closed.