I have a problem controlling the width of a table using the jQuery DataTables plugin. The table is supposed to be 100% of the container width, but ends up being an arbitrar
Check this solution too. this solved my DataTable column width issue easily
JQuery DataTables 1.10.20 introduces columns.adjust()
method which fix Bootstrap toggle tab issue
$('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
$.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
} );
Please refer the documentation : Scrolling and Bootstrap tabs
Setting widths explicitly using sWidth
for each column AND bAutoWidth: false
in dataTable
initialization solved my (similar) problem. Love the overflowing stack.
find another useful link about this problem and it resolved my problem.
<table width="100%">
<tr>
<td width="20%"> Left TD <td>
<td width="80%"> Datatable </td>
</tr>
</table>
Datatables force width table
Add this css class to your page, it will fix the issue:
#<your_table_id> {
width: inherit !important;
}
You have to leave at least one field without fixed field, for example:
$('.data-table').dataTable ({
"bAutoWidth": false,
"aoColumns" : [
null,
null,
null,
null,
{"sWidth": "20px"},
{ "sWidth": "20px"}]
});
You can change all, but leave only one as null, so it can stretch. If you put widths on ALL it will not work. Hope I helped somebody today!
I had a similar issue where the contents of the table were bigger than the table header and footer. Adding a div around the table and setting x-overflow seems to have sorted this issue: