How to get aoColumns settings object?
How to get aoColumns settings object?
I used to get the aoColumns object using the code below. It seems that I am unable to do this after upgrading. How should I go about doing this in the current version? I can see the object in the .setting() function but have no idea how to get to it.
var oTable = $("#" + tableId).dataTable();
var aoColumns = oTable.dataTableSettings[0].aoColumns;
var columns = [];
for(var i=0; i < aoColumns.length; i++) {
if(aoColumns[i].mDataType == undefined) {
columns.push({sTitle: aoColumns[i].sTitle, mData: aoColumns[i].mData});
} else {
if(aoColumns[i].mDataType != "hide4Export") {
columns.push({sTitle: aoColumns[i].sTitle, mData: aoColumns[i].mData, mDataType: aoColumns[i].mDataType});
}
}
}
Answers
The settings object is considered to be internal - as you are seeing it can, will and does change between versions. It is also not documented.
You could use
settings()
to get the settings object (keep in mind it returns an array).Allan
Correct. I actually just looked at my only other question and I was warned. For someone who is admittedly bad with reading and using javascript objects and arrays and is a learner by example. What would be the code to get to aoColumns inside settings()?
table.settings()[0].aoColumns
should do it.Allan