I'm trying to initialize my table as:
var table = $("#table-id").DataTable({
"columnDefs": [{
"width": "8%",
"targets": 0
}],
'bSort': false,
bPaginate: false,
bFilter: false,
bInfo: false,
buttons: [
'copy', 'excel', 'pdf'
]
});
But I'm getting an error on Chrome's console that says:
Uncaught TypeError: Cannot read property 'copy' of undefined at dataTables.buttons.min.js:17
I'm trying to initialize my table as:
var table = $("#table-id").DataTable({
"columnDefs": [{
"width": "8%",
"targets": 0
}],
'bSort': false,
bPaginate: false,
bFilter: false,
bInfo: false,
buttons: [
'copy', 'excel', 'pdf'
]
});
But I'm getting an error on Chrome's console that says:
Share edited Dec 2, 2015 at 8:04 Alexander Suraphel asked Dec 2, 2015 at 7:49 Alexander SuraphelAlexander Suraphel 10.6k11 gold badges59 silver badges96 bronze badges 2Uncaught TypeError: Cannot read property 'copy' of undefined at dataTables.buttons.min.js:17
-
1
Note you're missing a
}
- although I assume that's just a typo otherwise you'd be seeing a different error. – Rory McCrossan Commented Dec 2, 2015 at 7:53 - 1 @RoryMcCrossan I was just a typo when asking this question :) – Alexander Suraphel Commented Dec 2, 2015 at 8:04
1 Answer
Reset to default 3It looks like you are missing the appropriate plug-in to include the buttons. Take into account that datatables buttons "are not built into the core, but rather than be included as and when you need them" (buttons doc). Hence, I would suggest you to either you use the download builder to customize your lib, or include them in separate files. I.e., the following libs are included in the buttons example:
- //code.jquery./jquery-1.11.3.min.js
- https://cdn.datatables/1.10.10/js/jquery.dataTables.min.js
- https://cdn.datatables/buttons/1.1.0/js/dataTables.buttons.min.js
- //cdn.datatables/buttons/1.1.0/js/buttons.flash.min.js
- //cdnjs.cloudflare./ajax/libs/jszip/2.5.0/jszip.min.js
- //cdn.rawgit./bpampuch/pdfmake/0.1.18/build/pdfmake.min.js
- //cdn.rawgit./bpampuch/pdfmake/0.1.18/build/vfs_fonts.js
- //cdn.datatables/buttons/1.1.0/js/buttons.html5.min.js
- //cdn.datatables/buttons/1.1.0/js/buttons.print.min.js
Also, you will need the following dom modifier:
dom: 'Bfrtip',
Working jsfiddle demo: https://jsfiddle/jufjn9ux/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744881080a4598841.html
评论列表(0条)