deferLoading

Since: DataTables 1.10

Delay the loading of server-side data until second draw.

Description

When using server-side processing, the default mode of operation for DataTables is to simply throw away any data that currently exists in the table and make a request to the server to get the first page of data to display. This is fine for an empty table, but if you already have the first page of data displayed in the plain HTML, it is a waste of resources. As such, this option exists to allow you to instruct DataTables to not make that initial request, rather it will use the data already on the page (no sorting etc will be applied to it).

deferLoading is used to indicate that deferred loading is required, but it is also used to tell DataTables how many records there are in the full table (allowing the information element and pagination to be displayed correctly). In the case where a filtering is applied to the table on initial load, this can be indicated by giving the parameter as an array, where the first element is the number of records available after filtering and the second element is the number of records without filtering (allowing the table information element to be shown correctly).

Note that this option only has effect when serverSide is enabled. It does not have any effect when using client-side processing.

Types

integer

Description:

When given as an integer, this enables deferred loading, and instructs DataTables has to how many items are in the full data set.

array

Description:

As an array, this also enables deferred loading, while the first data index tells DataTables how many rows are in the filtered result set, and the second how many in the full data set without filtering applied.

Default

  • Value: null

Examples

57 records available in the table, no filtering applied:

$('#example').dataTable( {
  "serverSide": true,
  "ajax": "scripts/server_processing.php",
  "deferLoading": 57
} );

57 records after filtering, 100 without filtering (an initial filter applied):

$('#example').dataTable( {
  "serverSide": true,
  "ajax": "scripts/server_processing.php",
  "deferLoading": [ 57, 100 ],
  "search": {
    "search": "my_filter"
  }
} );

Related

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