Since: DataTables 2.0

Get the widths of a group of columns.


This method matches the singular column().width() method in that it gets the widths of columns, but in this case operates over multiple columns and will return an array of values for the selected columns. If you need an overall width, you can then use reduce() to sum them.

As with column().width() it is important to note that the result given is the "outer width" of the cells for the target columns.

The returned numbers might not be an integer, depending on the browser's table rendering.


function columns().widths()


Compute the widths of the selected columns.


The widths of the columns in pixels.


Get the width of a group of columns:

let table = new DataTable('#example');

let widths = table.columns([0, 1, 2]).widths();

Get the width of all columns:

let table = new DataTable('#example');

let width = table
	.reduce(function (accum, val) {
		return accum + val;
	}, 0);


The following options are directly related and may also be useful in your application development.