Column auto-resize not working.

Column auto-resize not working.

beerygazbeerygaz Posts: 16Questions: 9Answers: 0
edited August 2018 in DataTables 1.10

I'm using the sample code to add column filters documented here:
https://datatables.net/extensions/fixedheader/examples/options/columnFiltering

No matter what I try, I can't seem to resize my columns. I've tried autoWidth: true I've tried the width: "10%" option in the columns: [] definition, but all my columns seem to be fixed width.

EDIT

This is definitely related to this bit of code:

 $('#ALPR_Reads thead tr:eq(1) th').each(function (i) {
            var title = $(this).text();
            $(this).html('<input type="text" placeholder="Search ' + title + '" />');
            $('input', this).on('keyup change', function () {
                if (table.column(i).search() !== this.value) {
                    table
                        .column(i)
                        .search(this.value)
                        .draw();
                }
            });
        });

Obviously this is being called after the column sizing is calculated and redrawing with fixed width columns. I have no idea how to fix this though.

Answers

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

    Hi again @beerygaz ,

    Take a look at this example here - the age column has been made much larger (50%). Note though that it will only fill that space if the other columns allow it - if you shrink the window, that 50% reduces as the other columns need space for their text.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.