{hero}

colvis

Since: Buttons 1.0.0

A button collection that provides column visibility control.
Please note - this property requires the Buttons extension for DataTables.

Description

This button will create a collection button that when activated will show a list of the columns in the table and provide the end user with the ability to toggle column visibility to suit their own requirements.

Options

This button can have the following options set in its configuration object to customise its actions and display:

Examples

DataTables initialisation: Show the colvis button with default options:

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

Direct initialisation: Show the colvis button, but do not include the first column in the list of columns:

new $.fn.dataTable.Buttons( table, {
	buttons: [
		{
			extend: 'colvis',
			columns: ':gt(0)'
		}
	]
} );

Customisation of the button text for the individual columns:

$('#myTable').DataTable( {
	dom: 'Bfrtip',
	buttons: [ {
		extend: 'colvis',
		columnText: function ( dt, idx, title ) {
			return (idx+1)+': '+title;
		}
	} ]
} );