Daniela Maia Daniela Maia - 4 months ago 33
CSS Question

print datatables footer columns functioning incorrectly

I want to print a table - 5 columns - with a footer.

The footer:

<tfoot>
<tr>
<th colspan="4" style="text-align:right">Total:</th>
<th></th>
</tr>
</tfoot>


The problem is: in the print view, the footer appears with 'Total' from columns 0 to 3.

I saw this answer by the author of Datatables, Allan

https://www.datatables.net/forums/discussion/comment/88923/#Comment_88923

and it looks like there's no official solution. Maybe do some workaround.

Answer

I did some workaround, it affects slightly the appearance of the table, but prints the total in the right place.

<tfoot>
    <tr>
        <th colspan="3"></th>
        <th style="text-align:right">Total:</th>
        <th> </th>
    </tr>
</tfoot>

By changing colspan to 3, writing "Total" in the fourth column, and printing the total value in the fifth.