angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

cannot read property 'copy' of undefined

Open harshamaddineni opened this issue 10 years ago • 7 comments

Hi. i am trying to use copy, excel features in our application. the reference which i used is

http://l-lin.github.io/angular-datatables/#/withButtons

This is how i declared dt-options $scope.dtOptions = DTOptionsBuilder.newOptions() .withLanguage({ "search": "" }) .withOption('paging', false) .withOption('stateSave', true) .withOption('dom','frtip') .withOption('buttons',[ 'copy', 'print', 'excel']);

the js files that i included are datatables.buttons.js angular-datatables.buttons.min.js buttons.colVis.js buttons.flash.js buttons.html5.js buttons.print.js already i had jquery-datatables.js and angular-datatables.js. am i missing any js file? please help me out

harshamaddineni avatar May 10 '16 02:05 harshamaddineni

Did you include the module dependencies ? angular.module('showcase.withButtons', ['datatables', 'datatables.buttons']) If you did, I do not really see where the problem is.

What is the problem exactly ? The buttons not showing up ? The function not working ? ...

kevintc avatar May 10 '16 14:05 kevintc

yes i have included datatables.buttons.

var app= angular.module('app', ['datatables', 'datatables.buttons']); $scope.dtOptions = DTOptionsBuilder.newOptions() .withLanguage({ "search": "" }) .withOption('paging', false) .withOption('stateSave', true) .withOption('dom','frtip') .withOption('buttons', ['copy','print','excel']);

in console i am getting cannot read property 'ext' of undefined cannot read property 'Buttons' of undefined cannot read property 'ext' of undefined cannot read property 'ext' of undefined

the buttons are not showing up. could you please tell me the order of js files that i need to include in html page?

harshamaddineni avatar May 10 '16 14:05 harshamaddineni

Can you try using the following syntax :

DTOptionsBuilder.newOptions()
.withButtons([
    'colVis',
    'copy',
    'print',
    'excel'
]);

kevintc avatar May 10 '16 14:05 kevintc

DTOptionsBuilder.newOptions(...).withButtons is not a function. this is the error i am seeing.

the order of JS files i had in html file are

  1. buttons.colVis.js
  2. buttons.flash.js
  3. buttons.html5.js
  4. buttons.print.js
  5. angular-datatables.buttons.min.js
  6. jquery-dataTables.js
  7. angular-dataTables.js

please correct me if i am wrong. i am not able to use withButtons property. is it due to old angular-datatables.js version? i am using v0.3.1

harshamaddineni avatar May 10 '16 14:05 harshamaddineni

Looks like you are missing the following : <script src="bower_components/datatables.net-buttons/js/dataTables.buttons.min.js"></script>

You should reverse the order of your js files, 6, 7, 5 then 1-4

kevintc avatar May 10 '16 14:05 kevintc

now i changed the files as per your order i.e.

  1. jquery-dataTables.js
  2. angular-dataTables.js
  3. angular-datatables.buttons.min.js
  4. dataTables.buttons.js
  5. buttons.colVis.js
  6. buttons.flash.js
  7. buttons.html5.js
  8. buttons.print.js

even though i am not able to see buttons. but in console i am not seeing any errors

harshamaddineni avatar May 10 '16 14:05 harshamaddineni

You cannot nee the buttons because there is an option missing when you define the DOM. Try to replace .withOption('dom','frtip') with .withOption('dom','Bfrtip') Place 'B' where you want the buttons to appear, check https://datatables.net/reference/option/dom.

kevintc avatar May 11 '16 15:05 kevintc