Object doesn't support property or method 'fnSettings'
Object doesn't support property or method 'fnSettings'
I'm using DataTables version 1.7.2 and i have sample below initialization peace of code that.
var oTable;
function TableSorter(arr) {
if (arr == 'audit') {
oTable = $('#myTable').DataTable({
buttons: ['excel'],
"bJQueryUI": true,
"aaSorting": [[0, "desc"]],
"sPaginationType": "full_numbers",
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]]
});
}
}
I then have a button column on the table which when clicked calls the function below.
function ToggleSortEvent(mode) {
var oSettings = oTable.fnSettings();
var cols = oSettings.aoColumns;
for (var i = 0; i < cols.length; i++) {
cols[i].bSortable = mode;
}
}
The line var oSettings = oTable.fnSettings(); is throwing the following javascript error:
"JavaScript runtime error: Object doesn't support property or method 'fnSettings'" in IE
In chrome, the error message is as below
Uncaught TypeError: oTable.fnSettings is not a function
This started happening after adding the buttons extension because i wanted to support exporting to excel.
Answers
Top FAQ :-). fnSettings is a legacy API method while you are using the modern
$().DataTable()
initialisation. Usesettings()
in the new API if you want to continue using the modern API (I would suggest so).Allan