How to use `cell().index()` to get header text from selected column
How to use `cell().index()` to get header text from selected column
I'm looking at cell().index() and while I am able to get the correct row and column numbers when clicking a cell in the table, I was wondering if I could instead get the column header text of the selected row.
So if I have this:
var table = $(".histogram").DataTable();
$(".histogram tbody").on("click", "td", function () {
console.log('column: ' + table.cell(this).index().column);
console.log('row: ' + table.cell(this).index().row);
});
how would I need to tweak the code, so that instead of
column: 2
row: 1
i get the text-equivalents
column: Program
row(the column-0 value of that row) : 17-18
This would be useful so that I could filter another table on the page based on what a person clicks in this table, using parameters that make sense to the database function.
Answers
I figured out the "column text" portion of the code.