The angular-datatables
also provides an API in order to make the plugin TableTools
works with datatables.
See the API for the complete list of methods of the helper.
angular.module('datatablesSampleApp', ['datatables']).controller('withTableToolsCtrl', function ($scope, DTOptionsBuilder, DTColumnBuilder) {
$scope.dtOptions = DTOptionsBuilder
.fromSource('data.json')
// Add Table tools compatibility
.withTableTools('https://github.com/DataTables/TableTools/raw/master/swf/copy_csv_xls_pdf.swf')
.withTableToolsButtons([
'copy',
'print', {
'sExtends': 'collection',
'sButtonText': 'Save',
'aButtons': ['csv', 'xls', 'pdf']
}
]);
$scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID').withClass('text-danger'),
DTColumnBuilder.newColumn('firstName').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name')
];
});