即时更改 DataTables ColVis 排除选项?

Change DataTables ColVis exclude option on the fly?

是否可以即时更改 jQuery DataTables ColVis 扩展 exclude 选项?

我有资料table

    $("#calc_tabl").DataTable({
        paging: false,
        colVis: {
            buttonText: "Show/hide",
            //exclude: [0]
        },
        dom: 'C<"clear">frtiS'
    });

通过单击我想更改排除列的按钮,但我不需要重新加载整个 table。

    $("#calc_tabl").DataTable({
        paging: false,
        colVis: {
            buttonText: "Show/hide",
            exclude: [2,3]
        },
        dom: 'C<"clear">frtiS'
    });

有一个 fnSettings() 功能类似于

$(document).ready(function() {
  var oTable = $('#example').dataTable();
  var oSettings = oTable.fnSettings();
  alert( oSettings );
} );

也许可以从 oSettings 中提取 ColVis 选项?但是没有"ColVis"或者相同的参数

根据 jQuery DataTables 的创建者 this post by Allan Jardine 的说法,使用 ColVis 扩展无法即时更改排除的列。

另一种选择是重新初始化您的 table。