动态显示/隐藏列
var table = $("#tabList").DataTable({ ...});
//隐藏/显示
function hidColumn(colNum) {
var column = table1.column(colNum);
column.visible(!column.visible());
};
//显示
function showColumn(colNum) {
var bVis = $("#tabList").dataTable().fnSettings().aoColumns[colNum].bVisible;
$("#tabList").dataTable().fnSetColumnVis( colNum, true);
};
遇到的问题1:Uncaught TypeError: table.column is not a function
解决:var table1 = $(“#tabList1”).dataTable({ …}); 版本问题 将这里的.dataTables改为.DataTables
问题2:table.fnSetColumnVis is not a function ,table.fnSettings is not a function
解决: $(“#tabList1”).dataTable中的d应该为小写