columnsToggle

起始版本号: Buttons 1.0.0

一组按钮切换单个列的可见性

注意:这个需要使用Bottons扩展

说明(Description)

这是一组按钮,自动生成相同标题的文本列,可以用来切换列的可见性

The columnsToggleButton button type differs from the colvisButton type in that it does not extend the collectionButton type (although it could be assigned to a collection's buttons attribute if you wished). The buttons for each column are automatically expanded where this button is included.

选项(Options)

这个按钮有以下选项配置:

示例

Datatables初始化:显示每一列的按钮

$('#myTable').DataTable( {
    buttons: [ 'columnsToggle' ]
} );

Datatables初始化:只显示class名为toggle的按钮

$('#myTable').DataTable( {
    buttons: [ {
        extend: 'columnsToggle',
        columns: '.toggle'
    } ]
} );

直接初始化:在集合中显示每一列的按钮 ,和 colvis按钮是一样的

new $.fn.dataTable.Buttons( table, {
    buttons: [
        {
            extend: 'collection',
            buttons: [ 'columnsToggle' ]
        }
    ]
} );

http://datatables.net/reference/button/columnsToggle

Translation from DataTables.net, with permission