Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery DataTables - Set one column to take extra width

I am curious if there is a way to set one of the columns to 'absorb' any extra width. For instance, I want all the columns to have auto width to the smallest possible width that the data within allows (without text wrapping) and I want one column to expand to whatever width is necessary to fill the table to 100%.

Or if anyone knows how, to set the table width to automatically only take up the necessary width.

like image 454
JimmyJammed Avatar asked Nov 11 '11 01:11

JimmyJammed


People also ask

How do you control column width in DataTable?

How to fix column width in DataTable? The columns that are fixed in place by FixedColumns take their width from the parent DataTable. As such, the width of the column can be controlled using the columns. width option.

How do you set column width in lightning DataTable?

Set to 'fixed' for columns with equal widths. Set to 'auto' for column widths that are based on the width of the column content and the table width. The default is 'fixed'. Array of the columns object that's used to define the data types.


1 Answers

http://jsfiddle.net/pxfunc/gFa29/

table {width:100%;border:solid 2px #ddd;}
th, td {white-space:nowrap;border:solid 1px #eee;}
.fill {width:95%}
  • set the table to 100% width
  • set all cells to nowrap
  • set one of the td or th cells to a high % width to absorb the extra space
like image 93
MikeM Avatar answered Sep 26 '22 18:09

MikeM