I\'m using DataTable 1.10.9 (from https://datatables.net). Columns for the datatable are defined at the initialization step in javascript and each column has a unique name, e.g.
You can retrieve the initialization options through table.settings().init()
- and by that the columns
definition this way :
var columns = table.settings().init().columns;
When clicking on a cell / An example of a click handler that alerts the corresponding Your demo -> http://jsfiddle.net/6fstLmb6/ you can find the column index by (best practice in case of hidden columns) :
var colIndex = table.cell(this).index().column;
column.name
when a cell is clicked $("#example").on('click', 'td', function() {
//get the initialization options
var columns = table.settings().init().columns;
//get the index of the clicked cell
var colIndex = table.cell(this).index().column;
alert('you clicked on the column with the name '+columns[colIndex].name);
})
every()
example would bevar columns = table.settings().init().columns;
table.columns().every(function(index) {
console.log(columns[index].name);
})