auto width not working?

auto width not working?

dzidadzida Posts: 23Questions: 0Answers: 0
edited December 2009 in General
Hi,

I found strange behavior of datatables (v1.5.6). I have table with several columns and one of them is 'id' column which should have smallest width. With auto width enabled datatables gives 'id' column so much space that other columns (which contain some text) are forced to break line.

example:
'id' column stores number (max 3 digits) - 321px
'name' column stores names (up to 20-30 chars) - 91px

this is my code:
$(".datatable").dataTable({
"oLanguage": {
"sUrl": "/site_media/language/pl_PL.txt"
},
"bProcessing": true,
"bLengthChange": false,
"bPaginate": false,
"bAutoWidth": true,
"iDisplayLength": -1,
});

Is there any requirement (like setting fixed width for table or its container) to make auto width behave properly?

It looks really nice in examples on datatables.net but I don't know why on my site it looks so bad.

Regards

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi dzida,

    Very odd indeed. There is no requirement for setting the table width before display - but I've found that it is needed if you want the table to take up a certain amount of space (for example width:100% - otherwise the table takes up the minimum possible).

    Would you be able to provide a link to your page which is showing this problem? The fact that your id column is much wider than the name column looks very odd!

    Thanks,
    Allan
This discussion has been closed.