Can the serverSide flag be accessed from the table after creation?

Can the serverSide flag be accessed from the table after creation?

mikefinchmikefinch Posts: 2Questions: 1Answers: 0

I create a DataTable to use server side processing mode.

  var config = {};
  ...
  config.serverSide = true;
  config.ajax = { ... };

  var table = $( '#person-table' ).DataTable( config );

Later, some function of mine receives a DataTable as an argument. Can I determine if that DataTable is using server side processing mode, by inspecting any of its properties or calling one of its functions? For example:

  Util.reloadTable = function ( table )
  {
    // Reloading only works if the DataTable is using server-side processing mode.
    if ( table.something /* ??? */ ) 
    {
      table.ajax.reload( null, false );
    }

  }

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    If the opposite of serverSide is data in the DOM and no ajax, then you can call ajax.url() - it'll return null. If you're still using ajax, then call settings() - this is considered private but it'll get you what you want:

    if ($('#example').DataTable().settings()[0].oInit.serverSide === true) ...
    

    Colin

This discussion has been closed.