Datatable not showing properly in modal box
Datatable not showing properly in modal box
Hi
I am trying to show a datatable in a modal box, which opens when user clicks a button.
Although the datatable is loading properly but its overflowing outside the modal box.
What I want to do is,
display data table in modal box properly (I am okay if it hides some of the columns and adds a (+) to expand the view ..
same as responsive mobile/tab view.
You can see the problem here
URL : http://gadhiya.in/dispatch
UNAME: kaustubh.agrawal2012@gmail.com
PWD : 12345678
After login > Click transactions > click Dispatch > Click (New) > click (Select Sauda) button on the editor form
I have checked a few things out as below, but without any success
https://datatables.net/examples/api/tabs_and_scrolling.html
https://datatables.net/forums/discussion/41870/column-width-not-working
https://stackoverflow.com/questions/25215750/datatables-does-not-becomes-responsive-on-bootstrap3-modal-dialog
Please help me with this.
Thanks.
This question has an accepted answers - jump to answer
Answers
Add
width="100%"
to yourtable
you are inserting into the document and also you'll probably need to enablescrollX
for that table since its content is wider than the visible area.Finally you should call
columns.adjust()
when the modal is made visible (or initialise the DataTable once the modal is visible).Allan
Hi allan,
I have tried all your suggestions.. but it dosent seem to be working .
you can check my JS in this file
http://gadhiya.in/web/js/dispatch.js
in fact the scrollX itself is not working.
When the screen size is greater than 765px (PC) it does not work, but when I reduce the browser width below 760, the table fits in the modal window properly.
Kindly help me with this.
Regards
Kaustubh
Ah - the problem is that you have a
div class="container"
element inside your modal, in from the Bootstrap CSS:Thus resulting in the width being incorrect. It isn't a DataTables issue I'm afraid, but one in how you are using Bootstrap.
Allan
Hi Allan
You are awesome!!!
I wasted a lot of time figuring it out.. finally gaveup and asked for help..!!
Thanks a lot !!!
Thanks a lot !!!
Thanks a lot !!!
Thanks a lot !!!
ok, Kaustubh and Allan, let me add a couple:
Thanks a lot !!!
Thanks a lot !!!
Thanks a lot !!!
Based on Kaustubh's example I got it done pretty easily.
I have a bootstrap modal with a child data table in it opening on button click of the parent data table. Here is the button definition:
The rest was straight forward based on Kaustubh's HTML. Here is mine:
The width="100%" and "autoWidth": true solved it! Thanks Allan!
.fade:not(.show) {
opacity: 0;
}
you sholud change opacity in datatables.css file to:
.fade:not(.show) {
opacity: 1;
}
HOLA BUENOS DIAS YO TENGO EL PROBLEMA DE QUE NO FUNCIONA MI BUSCADOR DE DATATABLE EN EL CUADRO MODAL
HELP PLEASE
HELLO GOOD MORNING I HAVE THE PROBLEM THAT MY DATATABLE SEARCHER DOES NOT WORK IN THE MODAL BOX
@MarKAngel85 We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin