How to use rowspan and colspan in tbody using datatable.js?

You can hack around the lack of colspan support by adding an “invisible” cell for every cell that’s eliminated:

<tr>
 <td colspan="3">Wide column</td>
 <td style="display: none;"></td>
 <td style="display: none;"></td>
</tr>
<tr>
 <td>Normal column</td>
 <td>Normal column</td>
 <td>Normal column</td>
</tr>

DataTables doesn’t complain, the table renders normally and sorting works (invisible columns sort as the empty string).

I haven’t tried this with rowspan.

Leave a Comment