How to increase column width size in datatables
How to increase column width size in datatables
table id="user">
<thead>
<tr class="theader">
<th>Order Id</th>
<th>Message</th>
<th>Date Created</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
$("#user").dataTable({
"bFilter": false,
"bAutoWidth": false,
"bProcessing" : false,
"bServerSide" : true,
"sAjaxSource" : "./getLogDetails.cpm"
});
Hi Friends.
My datatable getting the data from a spring controller and populating in datatables.
Here the Message column in the datatable rows are displaying properly if the data contains spaces between words.
If the Message Column contains big words that doesn't contain spaces then the Column is overflowing and going after the border of the table.I want to set the column width for datatable so that it will break after some text and display properly.
How can I set a column width for a datatable? Thanks!
Answers
I'm not sure the logic that you're going to have to implement to figure out how wide the column needs to be to fit all the text appropriately.
An idea off the top of my head is to figure out what the longest string in the column is, figure out the length of it, do some math for a conversion of string length > pixel width needed and then call the appropriate helper to change the width.
As far as actually changing the width of the column, that should be easy. http://datatables.net/reference/option/columns.width goes over how to make a column a specific width, and the column.Adjust should be exactly what you're looking for when you get to the point where you want to change the width.