I'm facing an issue with my data table created using datatables. I need to fix the first two columns, but when I do so, the other two columns overlap them while scrolling horizontally. If I remove the fixed columns, the scrolling works correctly without any overlap. Here is an example where the Capacity column is overlapping the Equipment Name: https://i.sstatic.net/AHlo6.png
Html Code:
<style>
.bg-dark {
background-color: #2980b9 !important;
}
.thead-dark th {
background-color: #2980b9 !important;
}
body {
font-family: 'Nunito Sans', sans-serif;
}
.table td,
.table th {
height: 1em;
font-size: 12px !important;
padding: 5px 5px;
}
.table-scroll {
overflow-x: scroll;
}
</style>
...
<p>Javascript Code:</p>
<pre><code><script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<!-- <script type="text/javascript" src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script> -->
<script
type="text/javascript"
src="{% static 'js/jquery.datatables.min.js' %}"
></script>
<script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/4.2.2/js/dataTables.fixedColumns.min.js"></script>
<script>
$(document).ready(function () {
var table = $("#equipmentCostData").DataTable({
fixedColumns: true,
fixedColumns: {
left: 2,
right: 0
},
responsive: true,
});
});
</script>
Is there a way to fix the first two columns without overlap while scrolling horizontally?