Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Cannot reinitialise datatable #250

Closed
giankotarola opened this issue Mar 17, 2015 · 6 comments
Closed

Cannot reinitialise datatable #250

giankotarola opened this issue Mar 17, 2015 · 6 comments

Comments

@giankotarola
Copy link

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?

@elensky
Copy link

elensky commented Mar 18, 2015

I have the same issue, in similar situation. For the first time DataTable work fine, but another tables do not work correctly. When I explored requests, I noticed the next situation: while one table is rendering, options from previos opened table are used.
This issue take place after updating to version 0.4.2 (on 0.4.1 all working fine)

@giankotarola
Copy link
Author

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.

@zafra6
Copy link
Contributor

zafra6 commented Apr 21, 2015

Hi GiankOtarola, maybe your problem is similar to the issue 262, the part when the table disappear from the view

@harshamaddineni
Copy link

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.

@solankin1576
Copy link

I have the same error can any one help me?

@l-lin
Copy link
Owner

l-lin commented Nov 25, 2017

Closing as issue is too old and the version is no longer maintained.

@l-lin l-lin closed this as completed Nov 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants