{hero}

$.fn.dataTable.tables()

Since: DataTables 1.10

Get all DataTables on the page.

Description

It can be useful to be able to get a list of the existing DataTables on a page, particularly in situations where the table has scrolling enabled and needs to have its column widths adjusted when it is made visible. This method provides that ability.

Please note that this is a static function and is accessed through the $.fn.dataTable object, not an API instance. It can be accessed at any time, even before any DataTables have been created on the page.

Type

function tables( [ visible ] )

Description:

Get all DataTable tables that have been initialised - optionally you can select to get only currently visible tables and / or retrieve the tables as API instances.

Parameters:
Returns:

Array or DataTables API instance containing all matching DataTables

Examples

Adjust the column widths of all visible tables:

$.fn.dataTable
	.tables( { visible: true, api: true } )
	.columns.adjust();

Adjust column widths when a table is made visible in a Bootstrap tab:

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
	$.fn.dataTable
		.tables( { visible: true, api: true } )
		.columns.adjust();
})