Problem with column width after sorting/filtering

Problem with column width after sorting/filtering

Louis C.Louis C. Posts: 1Questions: 1Answers: 0

Hello everyone,

I am experiencing a very annoying problem since I added columns on my datatable.

This is how I initialize my datatable :

dayTable = $('#dayTable').DataTable({
    dom: 'Brftip',
    buttons: [
        // 'columnsToggle'
    ],
    // "scrollX": true,
    autofill: true,
    "ordering": true,
    "info": false,
    // "searching": false,
    "order": [[ 1, "asc" ]],
    select: true,
    "paging": false,
    columnDefs: [
        { width: 300, targets: 3 },
    ],

});

Everything was working well when I had a few columns but since I added 10 columns, the width of my 4th column (index 3) isn't kept after I do any operation on my table (filtering, sorting...).

You can see the example below.

BEFORE

AFTER

I really need to keep the width of my fourth column.
Thank you very much for your help.

Louis

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    I suspect you need a call to columns.adjust(). If that doesn't help, 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

This discussion has been closed.