With the DataTables ColVis

The angular-datatables also provides an API in order to make the plugin ColVis work with datatables.

You need to add the file angular-datatables.colvis.min.js to your HTML file.

You also need to add the dependency datatables.colvis to your Angular app.

See the API for the complete list of methods of the helper.

angular.module('showcase.withColVis', ['datatables', 'datatables.colvis']) .controller('WithColVisCtrl', WithColVisCtrl); function WithColVisCtrl(DTOptionsBuilder, DTColumnBuilder) { var vm = this; vm.dtOptions = DTOptionsBuilder.fromSource('data.json') .withPaginationType('full_numbers') // Active ColVis plugin .withColVis() // Add a state change function .withColVisStateChange(stateChange) // Exclude the last column from the list .withColVisOption('aiExclude', [2]); vm.dtColumns = [ DTColumnBuilder.newColumn('id').withTitle('ID'), DTColumnBuilder.newColumn('firstName').withTitle('First name'), DTColumnBuilder.newColumn('lastName').withTitle('Last name') ]; function stateChange(iColumn, bVisible) { console.log('The column', iColumn, ' has changed its status to', bVisible); } }