My Data-table is functioning properly, but I am encountering an issue when using the same table on a small device
Snippet
var data = [...]
var columndef = [...]
$('#tbl').DataTable({
columns: columndef,
data: data,
scrollY: '50vh',
scrollCollapse: true,
paging: false
});
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
<table id="tbl" class="table table-striped table-bordered "></table>
While the table works fine on larger devices, when viewed on a smaller screen, the tbody
part scrolls horizontally while the thead
remains static, causing issues with the user interface.
To replicate the problem, resize the browser and scroll horizontally. Are there any alternative solutions available for this issue?