Column width is not auto-adjusting

Column width is not auto-adjusting

dizzydesdizzydes Posts: 5Questions: 3Answers: 0

My rows come in one by one via Ajax - the first row is enough to adjust the columns to fit, though.

I've tried running adjust on the table post creation:
and also further down once the rows have come in via Ajax calls. (That's why I couldn't add code in live, as I couldn't easily include the Ajax workflow). I have however used the debugger and uploaded my config information under afukos.

I've also tried the following command further down:

Any help greatly appreciated

Answers

  • kthorngrenkthorngren Posts: 21,150Questions: 26Answers: 4,918
    edited July 2019

    Do you have style="width:100%" defined on your table like this example?

    You have autoWidth disabled. Try enabling it to see if that helps.

    I believe you need to use draw() with columns.adjust() as shown in the example. However if your table is setup with the above and is visible when adding rows it should auto calc the column width and you wouldn't need columns.adjust().

    You could build a test case using Javascript data. You can build a small array of your example data then use to add the rows. For example:
    http://live.datatables.net/henivice/1/edit

    If the above doesn't help then please update my test case or create your own replicating the issue.

    Kevin

  • dizzydesdizzydes Posts: 5Questions: 3Answers: 0

    Thanks so much for your help - its fixed now.

    Turns out it was something hacky below I had done with CSS to cure two th's that were appearing prior.

        div.dataTables_scrollBody thead {
            display: none;
        }
    
This discussion has been closed.