Minimum column width
Minimum column width
mdiessner
Posts: 34Questions: 0Answers: 0
Hi Alan,
I am struggling with a DT that has a lot of columns where I am trying to optimize real estate on screen.
I have a currency column where the column title is Crn and the column content varies with currencies e.g. USD, EUR, GBP and so on. The maximum width is 3 upper case letters.
I have switched off sorting and tried to set the width on that column (e.g. index 1):
[code]
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 1 ] },
{ "sWidth": "20px", "aTargets": [ 1 ] }
],
[/code]
However, DT still assigns about 20-30% more column width/space than necessary.
Any ideas or hints?
Thanks a lot,
Rgds
Martin
I am struggling with a DT that has a lot of columns where I am trying to optimize real estate on screen.
I have a currency column where the column title is Crn and the column content varies with currencies e.g. USD, EUR, GBP and so on. The maximum width is 3 upper case letters.
I have switched off sorting and tried to set the width on that column (e.g. index 1):
[code]
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 1 ] },
{ "sWidth": "20px", "aTargets": [ 1 ] }
],
[/code]
However, DT still assigns about 20-30% more column width/space than necessary.
Any ideas or hints?
Thanks a lot,
Rgds
Martin
This discussion has been closed.
Replies
There might be padding on the header or body cell perhaps? There is at least 28px of padding added by the DataTables demo CSS.
Are you able to give me a link to the page so I can have a look and say for sure what exactly is happening?
Thanks,
Allan
Thanks for the quick reply.
I have stripped out most of my code and left the important bits, even though I am using bJQueryUI (not in this example!) you can see column Crn still having extra space on the right
http://live.datatables.net/ebilem/3/
Thanks a lot
Martin
Regards,
Allan
Thanks for that, however, I think there is more.
Any chance you can 'fix' this on the example used here?
http://datatables.net/styling/themes/smoothness
Choose any column. I am struggling to "take apart" working code with all the php in there to create a proper example for you.
Thanks
Martin
It looks like you want something like this:
[code]
table.display thead th div.DataTables_sort_wrapper {
padding: 0
}
table.display thead th {
padding: 3px
}
[/code]
http://live.datatables.net/abetor/edit#javascript,html
Allan
Thanks so much!
Martin