preDrawCallback

Since: DataTables 1.10

Pre-draw callback.

Description

The partner of the drawCallback callback, this function is called at the very start of each table draw. It can therefore be used to update or clean the display before each draw (for example removing events), and additionally can be used to cancel the draw by returning false. Any other return (including undefined) results in the full draw occurring.

Type

function preDrawCallback( settings )

Parameters:

Examples

Remove bound events from cells in the table's body:

$('#example').dataTable( {
  "preDrawCallback": function( settings ) {
    $('#example tbody').off( 'click', 'td' );
  }
} );

Cancel the table draw if #test has a value of 1:

$('#example').dataTable( {
  "preDrawCallback": function( settings ) {
    if ( $('#test').val() == 1 ) {
      return false;
    }
  }
} );

Related

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