2

I have table defined in html as <table id="tableDynamic"></table>

And I am updating table dynamically as

    $('#tableDynamic').DataTable( {
        columns: [
            { title: data[0] },
            { title: data[1] },
            { title: data[2] },
],

        "columnDefs": [
            {
                "render": function (data, type, row){
                    return '<a>' + row[0]  +'</a>';

                },
                "targets": 0
            },
        ]
    } );
}

How can I add tooltip just to specific column data[2]

4
  • 2
    datatables.net/forums/discussion/32240/… Commented Apr 26, 2017 at 19:00
  • this one worked too $("#tableDynamic > thead > tr > th:nth-child(3)").tooltip({title:"tooltipText"}); Commented Apr 26, 2017 at 19:11
  • You could also target it with jQuery. Commented Apr 26, 2017 at 19:36
  • For version 2.3.2, I was able to just add a tooltip to a header in the columnDefs like this: title: '<span title="My Tooltip">Header</span>',. I played around with doing it dynamically, and it also seemed to work, but your mileage may vary. Try this: title: <span title="My Tooltip">${data[2]}</span> Commented Aug 14 at 16:06

1 Answer 1

1

You could also do it like this (call any other javascript after Datable initialisation is complete):

 $('#tableID').DataTable({

    [...]

   fnDrawCallback: function(oSettings, json) {
      //Call JS here
      alert( 'DataTables has finished its initialisation.' );        
      tooltip('.selector', 'theme');
    }

  });

I asked a somewhat similar question here. Look at YouneL answer for more details, and an example to do the same with a call back.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.