Get column header with Parent child

Get column header with Parent child

DorababuDorababu Posts: 17Questions: 2Answers: 0
edited February 2018 in Free community support

How can I get the column header when there is same header present in parent child datatable

var table = $('#example').DataTable();
 
$('#example tbody').on( 'click', 'td', function () {
    var idx = table.cell( this ).index().column;
    var title = table.column( idx ).header();
 
    alert( 'Column title clicked on: '+$(title).html() );
} );

On clicking child row I am not getting the header name

Answers

  • DorababuDorababu Posts: 17Questions: 2Answers: 0
    edited February 2018

    I got the solution by the following

    $("#example").on("click", 'tr td:not(:first-child)', function (){
    var $td = $(this),
    th = $('#example th').eq($(this).index());
    alert(th.text()); 
    });
    
This discussion has been closed.