How to control column width?

How to control column width?

gh2mgh2m Posts: 63Questions: 16Answers: 0

I tried using inline style in column header and/or cell in that column, say style="width:100px", or style="width:20%", etc. But it didn't work. Table column width seems to be automatically adjusted based on the length of data in that column. Maybe there is a setting on DataTable I can use?

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • gh2mgh2m Posts: 63Questions: 16Answers: 0

    Here is my test case http://live.datatables.net/sapabago/1/
    I would like to make column 4 a fixed width or 50%. Column 4 has significant amount of data then other columns.

  • gh2mgh2m Posts: 63Questions: 16Answers: 0

    Plus I can't use the full browser window because of the requirement. So if you re-size the browser window to half width of your computer screen, it looks very bad, the row is wrapped to more than 15 lines.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Ah yep, you should be able to use columns.width and set it to 50% - I have on my wide screen and that works fine. The problem with smaller screens is the number of columns, and the width of the container. You'll need to use scrollX or make the container a larger width,

    Colin

This discussion has been closed.