动态更改DataTables ColVis排除选项?

时间:2015-09-14 11:49:39

标签: jquery datatables

是否可以动态更改jQuery DataTables ColVis扩展程序exclude

我有数据表

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

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

    $("#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”或相同的参数。

1 个答案:

答案 0 :(得分:0)

According to this post by Allan Jardine, creator of jQuery DataTables, changing excluded columns on the fly wasn't possible with ColVis extension.

Alternative option could be to re-initialize your table.