Object doesn't support property or method 'fnSettings'

Object doesn't support property or method 'fnSettings'

txt1txt1 Posts: 5Questions: 3Answers: 0

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

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Top FAQ :-). fnSettings is a legacy API method while you are using the modern $().DataTable() initialisation. Use settings() in the new API if you want to continue using the modern API (I would suggest so).

    Allan

This discussion has been closed.