VOOZH about

URL: https://www.geeksforgeeks.org/jquery/datatables-autowidth-option/

⇱ DataTables autoWidth Option - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

DataTables autoWidth Option

Last Updated : 21 Jul, 2021

DataTables is jQuery plugin that can be used for adding interactive and advanced controls to HTML tables for the webpage. This also allows the data in the table to be searched, sorted, and filtered according to the needs of the user. The DataTable also exposes a powerful API that can be further used to modify how the data is displayed.

The autoWidth option is used to specify whether the automatic calculation of the column width in the DataTable is enabled or not. This calculation takes a little time and may be disabled when the column widths are explicitly passed using the columns.width option.

Syntax:

{ autoWidth: value }

Parameters: This option has a single value as mentioned above and described below:

  • value: This is a boolean value that denotes whether the automatic calculation of column width is enabled. The default value is true.

The examples below illustrate the use of this option.

Example 1: In this example, the autoWidth option is set to its default state, which means that the column widths will be calculated automatically.

Output:

👁 Image

Example 2: In this example, the autoWidth option is set to false and the column widths are passed as an array.

Output:

👁 Image

Reference: https://datatables.net/reference/option/autoWidth

Comment
Article Tags:

Explore