Consider adjusting table-layout
to fixed
by incorporating this CSS snippet:
table.display {
table-layout: fixed;
}
By implementing this change, the new width values will be applied according to your requirements. Hopefully, this solution proves effective for you. Thank you.
To delve deeper into the Table-Layout CSS property, refer to this resource.
In your scenario where "bAutoWidth": false
is being used, manual adjustment of column widths is necessary. Instead of defining widths using "aoColumns"
, you can adopt the following approach:
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "sWidth": "50px", "aTargets": [0,1,2,3,4,5,6,9,11,12,13,14,15] },
// ^ Consistent width for all columns (excluding Tel.1, Tel.2, and Fecha).
{ "sWidth": "80px", "aTargets": [7,8,10] },
// ^ Specific width for 3 chosen columns.
],
Your revised oTable code snippet appears as follows:
var oTable = $('#maintable').dataTable( {
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "sWidth": "50px", "aTargets": [0,1,2,3,4,5,6,9,11,12,13,14,15] },
{ "sWidth": "80px", "aTargets": [7,8,10] },
],
"aaSorting": [[1, 'asc']],
"scrollY": 500,
"scrollX": true,
"bAutoWidth": false,
"language": {
"lengthMenu": "Display _MENU_ data per page.",
"zeroRecords": "Nothing found.",
"info": "Showing _PAGE_ of _PAGES_",
"infoEmpty": "No data available",
"infoFiltered": "(filtered from _MAX_ total records)",
"search": "Search:",
"paginate": {
"first": "First",
"last": "Last",
"next": "Next",
"previous": "Previous"
}
}
});