Weird behavior when option "scrollX" is set to "true"
Weird behavior when option "scrollX" is set to "true"

When I load the page, the data-table is being rendered really weird when option "scrollX" is set to "true". Have a look at my code:
$(document).ready( function () {
$('#tblSales').DataTable({
"language": {
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Portuguese-Brasil.json"
},
"lengthMenu": false,
"bLengthChange": false,
"scrollX": true,
"responsive": true,
"pageLength": 5
});
});
Now, here is how it is displayed:
If I click on a thead, e.g. "Situação"(or any other), it goes back to what was expected, see image below:
Then I went to the code trying to find why this weird behavior, and when I set "scrollX"
to false
then the table rendered just fine. But without being able scroll horizontally.
Does anybody know what the heck is going on here?
usefull:
<!--> css being used -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css"/>
<div class="container col-md-12 tblHolder" >
<table id="tblSales" class="table table-bordered table-responsive-md table-condensed" cellspacing="0">
<!--code omitted for clarity -->
<!-- data table -->
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js" type="text/javascript"></script>
Answers
Can you add
width="100%"
orstyle="width: 100%"
to yourtable
please?Allan
Nice, but I already tried this one. I will keep the
width
to100%
Can you link to a page showing the issue so we can debug it if that didn't resolve the issue please.
Allan
Alright. But as I am sing .net core framework I will be pasting here the client-side code, ok?
But as you can see here datatables example it is working fine.
I don't see the
width
orstyle
attribute on yourtable
element that we discussed before:Should be:
Allan
Thanks, but as I mentioned before, I already did it, and it did not fix the problem.
I am setting the
width
to100%
. What else could be the source of my issue?I'm sorry, but without a link to a page showing the issue there isn't anything I can do as I can't debug the problem. I'm just going on what you show above, which didn't include the attributes which is why I mentioned it again.
Allan