我正在使用jQuery DataTables,并且过去两天一直在尝试为我的datatables添加标题列的工具提示,但是一直没有成功。
我使用了datatables网站上的示例,在行数据中添加了工具提示,但是那并没有起作用。我只看到一个工具提示,甚至没有获得列的标题。
以下是我目前的代码。
if (oTable != null) {
oTable.fnClearTable();
oTable.fnAddData(columnData);
} else {
oTable = $('#caseDataTable').dataTable({
"bDestroy": true,
"aaData": columnData,
"aoColumnDefs": columnNames,
bFilter: true,
bAutoWidth: true,
autoWidth: true,
"responsive": true,
dom: 'Bfltip',
buttons: [
{
extend: 'colvis',
postfixButtons: ['colvisRestore'],
collectionLayout: 'fixed two-column'
}
],
"fnDrawCallback": function() {
if (typeof oTable != 'undefined') {
$('.toggleCheckBox').bootstrapToggle({});
}
$('#caseDataTable thead tr').each(function () {
var sTitle;
var nTds = $('td', this);
var columnTitle= $(nTds[0]).text();
this.setAttribute('title', columnTitle);
});
/* Apply the tooltips */
$('#caseDataTable thead tr[title]').tooltip({
"delay": 0,
"track": true,
"fade": 250
});
}
});
}