Magnar Myrtveit Magnar Myrtveit - 6 months ago 20
jQuery Question

Prevent loading data for the initial page when using server-side processing

Is there a way to prevent loading the rows for the initial page via

AJAX
when using
DataTables
with server-side processing?

When the page is loaded, the rows for the first page are already available in the
HTML
. I would like
DataTables
to use the rows already available in the
DOM
for the initial page. When sorting/searching/paging, the data to be shown must of course be loaded using
AJAX
, but this is not necessary for the initial page, in my case.

Answer

Use deferLoading option which is there to delay the loading of server-side data until second draw. You just need to provide total number of records in your dataset.

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