How to fix the table's column width?
How to fix the table's column width?
dmjsophia
Posts: 4Questions: 0Answers: 0
hello there!
I'm new to DataTables.
I want to fix the column's width, because the auto generated width is really ugly looking.
would you please tell me how to achieve this goal?
Thanks a lot!
I'm new to DataTables.
I want to fix the column's width, because the auto generated width is really ugly looking.
would you please tell me how to achieve this goal?
Thanks a lot!
This discussion has been closed.
Replies
you can set widths for each/any column in aoColumns/aoColumnDefs with sWidth - or set them in the HTML table, DataTables will inherit those widths.
But I've tried sWidth in the following ways:
[code]
"aoColumnDefs": [
{ "sWidth": "20%", "aTargets": [ 0 ] },
{ "sWidth": "15%", "aTargets": [ 1 ] },
{ "sWidth": "15%", "aTargets": [ 2 ] },
{ "sWidth": "15%", "aTargets": [ 3 ] },
{ "sWidth": "15%", "aTargets": [ 4] },
{ "sWidth": "20%", "aTargets": [ 5 ] },
{ "sWidth": "20%", "aTargets": [ 6 ] }
]
[/code]
and
[code]
"aoColumns": [
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "15%" },
{ "sWidth": "20%" },
{ "sWidth": "20%" }
]
[/code]
in theory the first four column should have the same width. But atrangely the result is not like this, and as a result the table it generated is not that beautiful.
I'm puzzled by this, and I've tried to change the "15%" to "30px", but it also doesn't work.
Would you please tell me how to solve this problem?
Thanks a lot!