Reputation: 728
How can I get the TH of a TD in Datatables? Right now I have a code which I can use to add an attribute to the TD's on a datatable:
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td', nRow).attr("title","PUMMM");
//takes the tds from the row and assigned title attribute
}
What I want to do is to put a different attribute depending on the header that the particular td have.
Upvotes: 0
Views: 126
Reputation: 2819
Do you mean something like this? Sorry, i dont know this plugin...
var columNumber = 0;
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
$('td, th', nRow).each(function(){
var $this = $(this);
if($this[0].tagName == "TD"){
switch(columnNumber)
{
case 0:
$this.attr("title","Column 0");
break;
case 1:
$this.attr("title","Column 1");
break;
.
.
.
.
}
columnNumber++;
}
});
}
Upvotes: 1