{hero}

deferLoading

Since: DataTables 1.10

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

Deprecated

As of v1.13 this feature has been deprecated. This feature has not yet been scheduled for removal, but its use is discouraged and the alternatives discussed below should be used.

This option is largely irrelevant for the modern web. It was added when search engines wouldn't index Ajax data, but that is no longer the case, and this option just means you need to duplicate rendering logic in the server and the client. It will be removed in v2.

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 as 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.