1

Like this I can return the value of the current row:

"columnDefs": [

  {
    "render": function (data, type, row) {
     return data ;
 },

What I am actually looking for is the name of the current column. I tried:

"columnDefs": [

  {
    "render": function (data, type, row) {
     return column().name ;
 },

But this did not work.

peace_love
  • 6,229
  • 11
  • 69
  • 157

1 Answers1

1

If you specify a targets in your columnDefs you could do the following by adding a meta parameter :

"columnDefs": [
    {
        targets: 0,
        "render": function (data, type, row, meta) {
            var title = $('#example').DataTable().columns( meta.col ).header(); 
            var columnName = $(title).html();
            return columnName;
        }
    },
]

JSFiddle example (check the log) : https://jsfiddle.net/1jot32nz/

Alexandre Elshobokshy
  • 10,720
  • 6
  • 27
  • 57