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.

component using angular datatable and dttrigger when switch between components it gives error of ObjectUnsubscribedError because of dttriggers.next()

See original GitHub issue
rerender(): void {
        this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
          // Destroy the table first
          dtInstance.destroy();
          // Call the dtTriggers to rerender again
         this.dtTriggers.next();
        });
}

ngOnDestroy(){
        console.log("dashboard destroy is called");
        this.dtTriggers.unsubscribe();
}

image

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
Sir-Jcommented, Jul 9, 2018

Maybe need to create a component and in component use your directive? ngIf = false hide the component and destroy DOM. ngIf = true reinitialize the component and create new DOM. The component creates new dtTrigger.

1reaction
alwinaugustincommented, Jul 17, 2020

Unfortunately, when using ngIf, it destroys completely the DOM, so the dtTrigger is also destroyed, thus the error. One way to hide/show the table is to use the hidden property instead. Check this example. I do not have any other solution 😕

I tried to use the [hidden], but it is showing me error

DataTables warning: table id=releaseDatatable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR ObjectUnsubscribedErrorImpl in using angular ...
This error usually signifies that the subscriber or the main method is modified by some other code which led it to unsubscribing.
Read more >
Objectunsubscribederror Because Of Dttriggersnext 1241 ...
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Cannot refresh datatable when select option in dropdown menu
Hello, I just started using datatable in one of my Angular 6 project, and I'm really lost when it gets to refresh my...
Read more >
Angular 2 — ObjectUnsubscribedError Woes - Medium
Because the Subject can subscribe, it makes sense for it to have an unsubscribe() function to signal it's done, right? And if it's...
Read more >
What is dtTrigger in Angular 6? - Quora
dtTrigger is part of angular datatables packages (Angular DataTables), it is created as an object inside an Angular 6+ component with the following...
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