{hero}

destroy

Since: DataTables 1.10

Destroy any existing table matching the selector and replace with the new options.

Description

Initialise a new DataTable as usual, but if there is an existing DataTable which matches the selector, it will be destroyed and replaced with the new table. This can be useful if you want to change a property of the table which cannot be altered through the API.

Note that if you are not changing the configuration of the table, but just altering the data displayed by the table, it is far more efficient to use the ajax.reload() method (or rows.add() etc).

Type

This option can be given in the following type(s):

Default

  • Value: false

Example

Destroy an existing table and create a new one:

new DataTable('#myTable', {
	scrollY: '200px'
});

// Some time later, recreate without (no scrolling)
new DataTable('#myTable', {
	destroy: true
});

Related

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