Problem on columns width

Problem on columns width

khalen93khalen93 Posts: 4Questions: 1Answers: 0

Hello everyone I'm having troubles modifying my table's columns width:
datatable seems to set the width of the columns based on their headers; the problem is in this case I have a very long header but a very short column content, resulting in an oversized column. The same problem viceversa.

Ex:

| short header | very super long header |

| very long va**| short value**************|
| lue going in***|*************************** |
| new lines*****|****************************|


Stars mean "empy", I wrote it cause otherwise it would have been trimmed in the post.

Is there a way to make columns width depending on columns values and not header (I'd rather accept headers in new lines than contents)?. I tried a lot of things reading here and there in this forum: specifying width in columndefs, disabling autowidth, modifying css directly... but nothing seems to work.
I have a very basic implementation of the datatable, so I don't think there's need to post any code.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @khalen93 ,

    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

  • khalen93khalen93 Posts: 4Questions: 1Answers: 0

    Thank you Colin, but I noticed while I was writing an example that i couldn't reproduce my case: column width adapts to column content also... So I'm figuring out what's wrong and then try to provide an example.

  • khalen93khalen93 Posts: 4Questions: 1Answers: 0

    Ok it seems to be the fact that I display de table in the "initComplete" function that causes some problems. My case is similar to this, but in this case the long headers are getting new lines while in mine they are stretched all in one line...

  • khalen93khalen93 Posts: 4Questions: 1Answers: 0

    Uhm.. i feel a bit dumb but I find out the problem... it was in the css class i was using for headers which has "white-space: nowrap" and causes the problem... And so I think the question can be closed.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Ah tops, test cases are good as it helps take away code, so the problem is generally easier to see! Glad all working.

This discussion has been closed.