Clear the table of all data.
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
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.
Simply remove all rows of data from the table.
DataTables API instance
Clear the table of all data:
var table = $('#example').DataTable(); table .clear() .draw();
The following options are directly related and may also be useful in your application development.