Datatable with both excel button and lengthMenu
Datatable with both excel button and lengthMenu
Per77
Posts: 16Questions: 7Answers: 0
Hello all,
I need your help! How do I combine these two? I can not get it to work!
Please help!
Per
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
} );
$(document).ready(function() {
$('#example').DataTable( {
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
} );
} );
This discussion has been closed.
Answers
Thanks tangerine , but I can not get it to work. I probably got the wrong links/scripts?
<link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.5/css/buttons.dataTables.min.css">
Table:
<
table id="example" class="display nowrap" width="100%">
See this [FAQ}(https://datatables.net/faqs/index#buttons-page-length). Looks like you need to add
l
to thedom
option like thisdom: 'Blfrtip',
.If you still have problems please post a link to your page or a test case showing the issue. This way we can see what you have and see the exact problem to help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
My apologies - I forgot the "l"!
Thanks for you answers! Great tool to share!
If you could help me I would appreciate it alot. Can you make the buttons, header and the pagination to any red color also? Is that possible?
Here is my link (Hope you can see):
http://live.datatables.net/upgrade/2064/edit