How do you create a table with automatic column width sizing

How do you create a table with automatic column width sizing

perlmasterperlmaster Posts: 3Questions: 0Answers: 0
edited May 2012 in Feature requests
I am relatively new to datatables and I have run into a problem at the office. I want my table only to be as wide as it needs to be (eg. the sum of the maximum width from each of the columns). I have tried using the "bAutoWidth" option with no success. I have tried using the "aoColumnDefs" array to specify column definitions, but again no luck. Since this deals with code residing on a corporate I can't post a link to an example (because access from outside the corporate domain is rejected). We are running on a Linux system using an Apache web server. My browser is IE8 running on a Windows 7 laptop.


Here is the javascript init code written out by my perl script

print qq~



\$(document).ready(function(){
\$('#devices_table').dataTable({
"aaSorting" : [[0,"asc"]] ,
"sPaginationType" : "full_numbers" ,
"bAutoWidth" : treu ,
"iDisplayLength" : 20
});
});

~;


Here is the beginning of my table as written out by my perl script


print qq~


Device NameIP AddressDevice TypeStatusUptime


~;


And here is the end of the table as written out by my perl script

print "\n";



I also have the following CSS code in effect

div.dataTables_wrapper {
background-color: #003366;
color: white;
font-weight: bold;
}




Can anyone help a puzzled datatables rookie ?

Thanks.

Replies

  • perlmasterperlmaster Posts: 3Questions: 0Answers: 0
    I should add that in my above example code I have listed "bAutoWidth" as being set to "treu". That is just a cut-and-paste error, in my code it is actually set to "true".

    Perhaps I should have added that I only want the table to be as wide as it "needs to be".
This discussion has been closed.