Shrinking table to minimal width (autoWidth: true not working)

Shrinking table to minimal width (autoWidth: true not working)

yetyet Posts: 41Questions: 16Answers: 1

I am generating a DT from existing HTML markup. All columns have the same width although autoWidth: true is set. The DataTable() constructor does not contain any column specific width specs for the columns.

So how can I shrink the table width to its minimal width?

Answers

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    The DataTables CSS contains width:100% for the table. You would need to remove that from the CSS.

    Allan

  • yetyet Posts: 41Questions: 16Answers: 1
    edited September 2017

    You're correct with the width: 100% rule coming from the CSS however overriding the width using

    <table id="listing" style="max-width: 500px !important; width: 500px !important">
    

    does not help at all.

  • allanallan Posts: 61,824Questions: 1Answers: 10,131 Site admin

    It seems to work quite well here: http://live.datatables.net/bacipuxi/1/edit .

    Perhaps you can modify the test case to show me the issue?

    Thanks,
    Allan

This discussion has been closed.