l-lin / angular-datatables

DataTables with Angular
https://l-lin.github.io/angular-datatables/
MIT License
1.58k stars 487 forks source link

angular.js:15570 TypeError: DTOptionsBuilder.newOptions(...).withPaginationType(...).withButtons is not a function #1422

Closed Manya-92 closed 3 years ago

Manya-92 commented 4 years ago

Am getting .withButtons is not a function error while am trying to export my datatable in to excel sheet.I have added the following dependencies

<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons-bs/buttons.bootstrap.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons-bs/buttons.bootstrap.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons/buttons.colVis.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons/buttons.flash.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/jszip/jszip.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons/buttons.html5.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables.net-buttons/buttons.print.min.js"></script>
<script src="{context.links.resourceBaseUrl|s}/vendor/datatables/angular-datatables/plugins/buttons/angular-datatables.buttons.min.js"></script>

And my html is something like below <table datatable width="100%" class="table table-striped table-hover dtr-inline" id="example" role="grid" aria-describedby="{{message}}" dt-options="dtOptions" dt-column-defs="getColumnDefs(category)" dt-instance="dtInstanceCallback"

And my columns are defined as below

$scope.dtColumnDefs = { open: [ DTColumnDefBuilder.newColumnDef(1).notSortable(), DTColumnDefBuilder.newColumnDef(2).notSortable(), DTColumnDefBuilder.newColumnDef(5).notSortable(), DTColumnDefBuilder.newColumnDef(6).notSortable(), DTColumnDefBuilder.newColumnDef(7).notSortable() ], closed: [ DTColumnDefBuilder.newColumnDef(1).notSortable(), DTColumnDefBuilder.newColumnDef(2).notSortable(), DTColumnDefBuilder.newColumnDef(5).notSortable(), DTColumnDefBuilder.newColumnDef(8).notSortable(), DTColumnDefBuilder.newColumnDef(9).notSortable(), DTColumnDefBuilder.newColumnDef(10).notSortable(), DTColumnDefBuilder.newColumnDef(11).notSortable(), DTColumnDefBuilder.newColumnDef(12).notSortable() ] }

And my controller.js code is

angular.module('pe2eApp') .controller('DataViewCtrl', function ($scope, $state, $filter, sharedServices, DTOptionsBuilder, DTColumnBuilder, DTColumnDefBuilder, $q, $stateParams, $sce, $interval, $uibModal) { $scope.dtOptions = DTOptionsBuilder.newOptions() .withPaginationType('full_numbers') .withDOM('Blrtip') .withButtons([{ title : 'liveissues', text:'Export To CSV', exportOptions: { columns:[1,2,5]}
}
]);

Kindly let me know where I have gone wrong . Have been stuck here

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been closed due to inactivity. Please feel free to re-open the issue to add new inputs.