question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot reinitialise datatable

See original GitHub issue

I have a problem with data tables. I have 5 tables in differents tabs but with the same options and I use ng-repeat for show the information. I get the data with http request to the api. Ex:

$scope.dtOptions = DTOptionsBuilder.newOptions()
        .withBootstrap()
        .withOption('rowCallback', rowCallback)
        .withOption('deferRender', false)
        .withOption('sDom', "<'row'<'col-md-6 hidden-xs'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>")
        .withOption('oLanguage', {
            "sLengthMenu": "_MENU_",
            "sInfo": "Mostrando <strong>_START_ a _END_</strong> de _TOTAL_ entradas"
        })
        .withOption('sPaginationType', "bootstrap")
        .withOption('oClasses', {
            "sFilter": "pull-right",
            "sFilterInput": "form-control input-rounded ml-sm",
            "sWrapper": "dataTables_wrapper form-inline",
            "sLength": "dataTables_length blahblahcar"
        })
        .withOption('initComplete', function(){
            //bad but creating a separate directive for demo is stupid
            $(".dataTables_length select").selectpicker({
                width: 'auto'
            });
        });
    $scope.dtColumnDefs = [
        DTColumnDefBuilder.newColumnDef(0),
        DTColumnDefBuilder.newColumnDef(1),
        DTColumnDefBuilder.newColumnDef(2),
        DTColumnDefBuilder.newColumnDef(3),
        DTColumnDefBuilder.newColumnDef(4),
        DTColumnDefBuilder.newColumnDef(5),
        DTColumnDefBuilder.newColumnDef(6).notSortable()
    ];

When I update a data from a table, one of the others tables have to update, because the data have to go there. But when finish to splice and push to other $scope variable(add the data to the other table) I have this error: Cannot reinitialise DataTable. Can anyone help me?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
giankotarolacommented, Mar 19, 2015

I did some changes to the code and my problem changes a little(The alert didn’t show, but the table disappeared). The problem happens if I add the scroll plugins to the tables. Explaining all the work, I have a websocket connection that update my tables if there is a change in a row data, when the websocket get the message of the change, the code do the work and splice and push the data to the corresponding table, and I have to use $scope.$apply() to see the visual update, and after using $apply the table disappear from the view.

3reactions
harshamaddinenicommented, Jun 1, 2016

it is because the data table is trying to reinitialize. when you are having multiple data tables in different tabs, don’t call the methods to fetch data. just change only the tab. it will fix the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3. Warning: Cannot reinitialise DataTable
This error can often occur when trying to obtain a reference to the DataTable for working with the API. For example, you might...
Read more >
Datatables warning(table id = 'example'): cannot reinitialise ...
I am working with datatables example and getting an error like this when loading page: Datatables warning(table id = 'example'): cannot reinitialise data ......
Read more >
Datatables warning(table id = 'example'): cannot ... - SPGuides
In this tutorial, we will discuss how to fix the error, Datatables warning(table id = 'example'): cannot reinitialise data table.
Read more >
Datatable warning : cannot reinitialise datatable - MSDN
Hi ManDown,. According to your description, this error indicates that DataTables does not allow initialisation options to be altered at any time ......
Read more >
cannot reinitialise datatable jquery - Iodocs.com
DataTables warning (table id = 'dataTable'): Cannot reinitialise DataTable. To retrieve the DataTables object for this table, pass no arguments or see the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found