Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How to use `cell().index()` to get header text from selected column

$
0
0

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.


Viewing all articles
Browse latest Browse all 2364