Method to turn off 100% table width?

Method to turn off 100% table width?

EvanGossEvanGoss Posts: 2Questions: 0Answers: 0

In some instances, I'd like to prevent DataTables from setting tables to 100% width. I don't care for all the whitespace that results when a table doesn't have much data, such as 2 columns with a few numbers in each column (example).

It appears that DataTables adds "width:100%;" to the <table> and calculated widths (in pixels) to the <th> elements.

<table style="width:100%;">
  <thead>
    <tr>
      <th style="width:150px;">Column 1</th>
      <th style="width:150px;">Column 2</th>
    </tr>
  </thead>
</table>

What's the best method for preventing this so that the native browser column sizing is preserved?

Thanks,
Evan

Replies

This discussion has been closed.