Responsive bootstrap4 doesn't load?
Responsive bootstrap4 doesn't load?
sunny_s
Posts: 31Questions: 2Answers: 0
I want my table to be responsive and I use these cdn
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap4.min.js"></script>
but my table is not responsive
but from "network" I can see the scripts are here
This discussion has been closed.
Replies
It could simply be you are missing a couple CSS files. I took what you had above and created a test case for you:
http://live.datatables.net/yafazivu/1/edit
I added these two CSS includes:
https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css
https://cdn.datatables.net/responsive/2.2.3/css/responsive.bootstrap4.min.css
It seems to work and look correct now.
Kevin
Thank you for pointing out the missing css files.
my table still not responsive.
I am using row group, fixed header, these two work. And I need responsive as well
By the way, my row group is customize, it allows me to manually expand or collapse the rows. I'm sure if my js prevents my table from being responsive.
My js:
I might be missing it but it doesn't look like you are enabling responsive. Here are some examples of the different ways it can be enabled:
https://datatables.net/extensions/responsive/examples/initialisation/index.html
Kevin
silly me. I added
responsive: true
to my js file and I can see the table is responsive now.There's some layout issue with my table though. From the example I can see that the
th
andtd
have enough spacing in between.But my table, however, no spacing between the
th
and thetd
I suspect that is a CSS config. Can you update my example with your environment to show the issue? Or maybe a link to your page.
Kevin
item_dataTable.js
cdn
My js file comes after all the cdn
Although not exactly the same but you can see that when the table become responsive, there's not enough spacing between
th
andtd
http://live.datatables.net/beyapupu/5/edit