Change DataTable options/columns/columnDef

You can change the DataTable options, columns or columnDefs seamlessly. All you need to do is to change the dtOptions, dtColumns or dtColumnDefs of your DataTable.

ID First name Last name
1 Foo Bar
123 Someone Youknow
987 Iamout Ofinspiration

ID First name Last name
1 Foo Bar
123 Someone Youknow
987 Iamout Ofinspiration
angular.module('datatablesSampleApp', ['datatables']). controller('withOptionsCtrl', function ($scope, DTOptionsBuilder, DTColumnDefBuilder) { $scope.dtOptions = DTOptionsBuilder.newOptions(); $scope.dtColumnDefs = [ DTColumnDefBuilder.newColumnDef(0), DTColumnDefBuilder.newColumnDef(1).notVisible(), DTColumnDefBuilder.newColumnDef(2).notSortable() ]; $scope.changeOptions = function() { $scope.dtOptions = DTOptionsBuilder.newOptions() .withPaginationType('full_numbers') .withDisplayLength(2) .withDOM('pitrfl'); }; $scope.changeColumnDefs = function() { $scope.dtColumnDefs = [ DTColumnDefBuilder.newColumnDef(0).notVisible(), DTColumnDefBuilder.newColumnDef(1).notVisible(), DTColumnDefBuilder.newColumnDef(2).notSortable() ]; }; });