DataTables example Complex headers (rowspan and colspan)

When using tables to display data, you will often wish to display column information in groups. DataTables fully supports colspan and rowspan in the table's header, assigning the required order listeners to the TH element suitable for that column.

Each column must have one TH cell which is unique to it for the listeners to be added. By default DataTables will use the bottom unique cell for the column to attach the order listener, if more than one cell for a column if found. The orderCellsTopDT option can be used to tell DataTables to use the top cell if you prefer.

The example shown below has two sets of grouped information, grouped by colspan in the header.

NameHR InformationContact
PositionSalaryOfficeExtn.E-mail
NamePositionSalaryOfficeExtn.E-mail
Airi Satou Accountant $162,700 Tokyo 5407 a.satou@datatables.net
Angelica Ramos Chief Executive Officer (CEO) $1,200,000 London 5797 a.ramos@datatables.net
Ashton Cox Junior Technical Author $86,000 San Francisco 1562 a.cox@datatables.net
Bradley Greer Software Engineer $132,000 London 2558 b.greer@datatables.net
Brenden Wagner Software Engineer $206,850 San Francisco 1314 b.wagner@datatables.net
Brielle Williamson Integration Specialist $372,000 New York 4804 b.williamson@datatables.net
Bruno Nash Software Engineer $163,500 London 6222 b.nash@datatables.net
Caesar Vance Pre-Sales Support $106,450 New York 8330 c.vance@datatables.net
Cara Stevens Sales Assistant $145,600 New York 3990 c.stevens@datatables.net
Cedric Kelly Senior Javascript Developer $433,060 Edinburgh 6224 c.kelly@datatables.net
Showing 1 to 10 of 57 entries

The Javascript shown below is used to initialise the table shown in this example:

1
2
3
$(document).ready(function() {
    $('#example').dataTable();
} );

In addition to the above code, the following Javascript library files are loaded for use in this example: