How do I add a static row (for totals, etc) at the bottom of a table?

How do I add a static row (for totals, etc) at the bottom of a table?

totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
edited September 2011 in DataTables 1.8
Hi All,

Has anyone found a good way to have a static "TOTALS" row at the bottom of a particular column that doesn't get removed during filters/sorts, etc.? Obviously I could manually ad something below the table, but it would be nice to have it match the same theming, etc. -- preferably that of the table headers.

Thanks in advance!

Best

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    Off the top of my head, I would use jQuery to insert a new row from within the fnDrawCallback. Create a new function that calculates what your total should be and adds the new row with this total showing.

    I don't have a full sample for you, but I can give you this tip: in order to build your new row, you will need to know the number of columns to add as well (well, or the number of columns to put into your colspan). You can get this with an API function:

    [code]
    var numcolumns = this.oApi._fnVisbleColumns(oSettings);
    [/code]
This discussion has been closed.