autoWidth ignoring headers

autoWidth ignoring headers

leonpardleonpard Posts: 3Questions: 1Answers: 0
edited April 2023 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
The autoWidth seems to work fine with the data in the table but it ignores the headers of the table.
Is there a way to get it to go off the headers if the data is smaller than the header? we have a few fields that don't always get used and show up as "-" in the table when there is no data. This causes the headers to become misaligned with the data since the table does not stretch.

I found the same problem and question in forum above. does anyone know how to solve it ?thanks in advance.

I'm using datatables 1.13.4. most of the text on headers are longer that fields data. I set 'autowidth' to true. it showes no effect to headers.

This question has accepted answers - jump to:

Answers

  • leonpardleonpard Posts: 3Questions: 1Answers: 0
    edited April 2023

    update:
    1.I found autoWidth takes effect on headers in english. no effect on headers in chinese.
    2.
    autoWidth takes no effect when text is "current date"(text wrap to 2 lines) .
    It show effects when text is "current_date".

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    Please link to a test case showing the issue per the forum rules, so we can debug the issue.

    The language will have no effect on the column width calculations, other than that the content is different. We don't do any locale detection for the header widths.

    Here is a little example showing the header text longer than the column cell content: https://live.datatables.net/zuxeleme/1/edit .

    Allan

  • leonpardleonpard Posts: 3Questions: 1Answers: 0
    edited April 2023

    Thank you , I'm not familiar with the operation, but I finally uploaded an example
    it shows the header text in chinese longer than the cell content.
    https://live.datatables.net/zijoqalo/2/edit.
    Hope so many chinese text in table would not confuse you.

    however, Based on the example you show me, I found 'nowrap' there and I tried.it can take effect. but this doesn't seem to be the intention of 'nowrap'.I thought 'nowrap' only take effects on cells.

    leonpard

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Answer ✓

    nowrap will affect all cells in the table, including the header and footer cells, not just the body cells.

    Allan

Sign In or Register to comment.