data: in the dataTable()

data: in the dataTable()

XenCXenC Posts: 2Questions: 1Answers: 0
edited March 2015 in Free community support

See:
$('#example').DataTable( {
data: data,
columns: [
{ data: 'name' },
{ data: 'position' },
{ data: 'salary' },
{ data: 'office' }
]
} );

In the HTML file do we have to specify the <th> for each column header>? With the columns already specified in the source above is there an option to automatically provide the header for each column?

Answers

  • allanallan Posts: 63,676Questions: 1Answers: 10,497 Site admin

    Either:

    1. Have no cells in the HTML header of the table and use columns.title to have DataTables create the cells with a title.
    2. Specify exactly the same number of cells in the HTML header of the table. DataTables will throw an error if they are not identical.

    Allan

  • XenCXenC Posts: 2Questions: 1Answers: 0

    Hi Allan,

    Thank you for responding. I will certainly give this a try.
    Regards,

    Xen

This discussion has been closed.