{hero}

clear()

Since: DataTables 1.10

Clear the table of all data.

Description

This method simply removes all rows from the DataTables, resulting in a data length set of 0. New data might then be added using the rows.add() method.

Please be aware that this method will not automatically redraw the table with an empty data set. In order to redraw the table use the draw() method, which can be called simply as a chained method of the clear() method's returned object - for example table.clear().draw();. This is useful for performance when you would want to immediately add new rows to the table - you would only call the draw() method once all required rows have been added to help improve performance.

This method should not be used when serverSide is enabled. When server-side processing is enabled, the data should be deleted from the data store (i.e. an Ajax request to the server) and then draw() called. Deleting the client-side data will have no effect when server-side processing is enabled since the data would simply be restored on the next draw if the data is not removed from the server.

Type

function clear()

Description:

Simply remove all rows of data from the table.

Returns:

DataTables API instance

Example

Clear the table of all data:

var table = $('#example').DataTable();

table
	.clear()
	.draw();

Related

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