1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="core">
<name>clear()</name>
<summary>Clear the table of all data.</summary>
<since>1.10</since>
<type type="function">
<signature>clear()</signature>
<description>Simply remove all rows of data from the table.</description>
<returns type="DataTables.Api">DataTables API instance</returns>
</type>
<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 `dt-api 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 `dt-api draw()` method, which can be called simply as a chained method of the `dt-api 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 `dt-api draw()` method once all required rows have been added to help improve performance.
This method should not be used when `dt-init 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 `dt-api 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.
</description>
<example title="Clear the table of all data"><![CDATA[
var table = $('#example').DataTable();
table
.clear()
.draw();
]]></example>
<related type="api">data()</related>
<related type="api">row.add()</related>
<related type="api">rows.add()</related>
</dt-api>
|