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 exisiting table and create a new one:

$('#example').dataTable( {
  "srollY": "200px"
} );

// Some time later, recreate with just filtering (no scrolling)
$('#example').dataTable( {
  "filter": false,
  "destroy": true
} );

Related

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