Jquery | DataTables warning: table id - Cannot reinitialise DataTable

Author - Webner

If you try to set properties of Jquery datatable 2 times as below, it will give an error:

table = $('#product-data-table').DataTable({stateSave: true}) ;

table = $('#product-data-table').DataTable
({"aoColumns": 
 [
  {
 "bSortable": false },null,null,null
  ]
 });

“DataTables warning: table id=product-data-table – Cannot reinitialise DataTable”.

DataTables does not allow initialisation options to be altered at any time other than at initialisation time. Any manipulation of the table after initialisation must be done through the API and trying to set the initialisation options once the table has already been initialised will result in above error.
Solution is to set all the properties at initialisation time as follows:

table = $('#product-data-table').DataTable
        ({
        stateSave: true,
        "aoColumns": [
                      { "bSortable": false },
                      null,
                      null,
                      null
                      ]
        });

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Web development or any other software development assistance please contact us at webdevelopment@webners.com

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

One response on “Jquery | DataTables warning: table id – Cannot reinitialise DataTable

  1. Ivan Evans says:

    i have the same error even after initializing the data-table ones.
    ===========================================================
    DataTables warning: table id=mainTable – Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

    This the error it brings but after clicking ok the code works but the error message displays whenever i reload the page. Some help pliz.

    $(‘#mainTable’).dataTable( {
    destroy: true,
    retrieve:true,
    paging: false
    } );

Leave a Reply

Your email address will not be published. Required fields are marked *