Minimum column width

Minimum column width

mdiessnermdiessner Posts: 34Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
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

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Hi Martin,

    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
  • mdiessnermdiessner Posts: 34Questions: 0Answers: 0
    Hi 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
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Thanks for that! Yes indeed, it looks like its just a padding issue: http://live.datatables.net/ebilem/4/edit . I've added an override on the padding to show it there, but you might want to just change the CSS file, or at it more "correctly" into your own style files.

    Regards,
    Allan
  • mdiessnermdiessner Posts: 34Questions: 0Answers: 0
    Hi 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
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Hi 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
  • mdiessnermdiessner Posts: 34Questions: 0Answers: 0
    Perfect - as always spot on!
    Thanks so much!
    Martin
This discussion has been closed.