Export excel button not displaying and trying to get div.dt-buttons to wrap on mobile
Export excel button not displaying and trying to get div.dt-buttons to wrap on mobile

I have two issues with https://jyorkejudge.org/a_test.php
I started off trying to get the excelHtml5 button to show , code is below. the csvHtml5 button shows and works but the csvHtml5 button doesn't.
I tried to use the download builder again, making sure I selected Buttons, HTML5 Export and JSZip.
After I did this, the row of buttons changed on my mobile phone. Previously, on my phone, the buttons would wrap to multiple rows. I don't recall doing anything to get it to display this way, but I liked it. I'm including two screenshots from my mobile phone to show how the row of buttons is extending past everything else. Now I can't seem to get them to wrap.
layout: {
topStart: {
buttons: [
{
extend: 'edit',
editor: addresseditor,
text: 'Edit Address',
formButtons: [
{
text: 'Cancel',
action: function () {
this.close();
}
},
'Update'
]
},
// 'searchPanes'
'searchBuilder', 'pageLength','colvis', 'createState', 'savedStates','csvHtml5', 'csvHtml5'
]
},
This question has accepted answers - jump to:
Answers
It doesn't look like you included JSZip which is required for the Excel export button. See the
excelHtml5
docs for details. Open the link you have fordatatables.min.js
In the file you will see a URL to upgrade. Paste that URL into your browser and addJSZip
. Adding this should display the Excel export button.BTW you need to make sure the triple back ticks are on separate lines and don't have leading spaces for Markdown to work correctly. I updated your post to fix this.
Kevin
Thank you.
Now,.any idea how to wrap the buttons on a movile device?
Looks like you have duplicate Datatables CSS and JS inclusions:
Lines 4 and 16 go together. Lines 9 and 13 look like duplicates of 4 and 16. Choose one or the other to use and remove the duplicates. This is possibly causing styling conflicts and will likely cause other issues.
Does removing the duplicate includes solve the problem with the buttons?
Kevin
Also open
js/datatables.min.js
to see what is included in the file. It has PDFMake. You should remove lines 1 and 2 of the above code snippet to keep from loading PDFMake twice.Kevin
Thank you, I was able to clean up the js and css. I still cannot figure out a way to get the row of buttons in "dt-buttons" or "dt-layout-cell dt-layout-start" to wrap
Your test case has some errors and doesn't run. I didn't see anything obvious when I looked earlier. This test case, with the default DT styling, shows the buttons are responsive by default.
https://live.datatables.net/muyoqohi/1/edit
There must something on your page affecting the behavior. @allan will probably need to look.
I noticed you have this:
You should remove this because you are loading jquery.js in this:
Here are the included libraries:
Kevin
I may have found the problem. Inspecting this
div
:There is this CSS applied by navbar.css:
Removing
display: flex;
. seems to fix the issue. Before removingdisplay: flex;
pic:Unchecking
display: flex;
results in this display:Notice horizontal scrolling is now working and the buttons are responsive. The Datatables container is staying within the width of the page.
Not sure the best way to handle this but maybe you can change the CSS selector used for the navbar container to make that CSS only apply to the navbar. You might need to refer to the navbar's docs.
Kevin