Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DataTables max column width

I'm using jQuery DataTables in my .NET web application but how do I set a max width for one specific column, all the other columns should be auto sized (like they are now in my table)

EDIT

The DataTables did it correctly by itself, the problem was there was a very long word without spaces that cause the problem

like image 355
Mats Hofman Avatar asked Jul 16 '10 06:07

Mats Hofman


People also ask

What is autoWidth in dataTable?

Description. Enable or disable automatic column width calculation. This can be disabled as an optimisation (it takes a finite amount of time to calculate the widths) if the tables widths are passed in using columns.

How do I fit a Div data table?

You have two options: Remove columns to make it so it fits within the div element. Set overflow-y to scroll or auto in css on the containing div. This will cut off anything outside the div and allow the user to scroll to see it.


1 Answers

Your problem seems more CSS related ...

Using word-wrap in CSS would fix that issue, for columnX just add this to your CSS.

.columnX {
  word-wrap: break-word;
}

It would wrap even words without spaces based on your set width for the column.

See: https://developer.mozilla.org/en/css/word-wrap

like image 123
Justin Jenkins Avatar answered Oct 12 '22 23:10

Justin Jenkins