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.

dtInstance not initialized correctly

See original GitHub issue

I have modified datatables to new version 0.4.3 and i want to use $scope.dtInstance.reloadData(). But my object dtInstance is initialized like this:

screen shot 2015-06-16 at 11 43 45

  • and it should by like your example:
{
    "id": "foobar",
    "DataTable": oTable,
    "dataTable": $oTable,
    "reloadData": function(callback, resetPaging),
    "changeData": function(newData),
    "rerender": function()
}
  • strange thing is, when i call $scope.dtInstance.reloadData(), no error is show. It looks like that method works (but dont reload data) even if that method is not in object.
  • when i use older $scope.dtOptions.reload = true, it reload data (and dont throw error again)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
rosshayscommented, Jun 25, 2015

I ran into this problem myself. I tried the pen and it did work.

So I think what is happening based on some of the other angular things I’ve used is that the datatable directive is actually making its own scope, so if you do the following in your controller…

$scope.nested = {};
$scope.nested.dtInstance = {}

…and then in your HTML…

<table
    datatable=""
    class="table table-striped table-hover table-bordered table-condensed"
    dt-options="dtOptions"
    dt-columns=dtColumns
    dt-instance="nested.dtInstance">
</table>

…it seems to work. If this is intended, it should probably be made more clear in the documentation.

3reactions
joelcdoylecommented, Sep 4, 2015

I can attest that what @rosshays said is true. If your controller is nested inside another controller, you must use a nested scope or dtInstance will not work properly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dtInstance not initialized correctly #345 - CodePen
1. angular.module('datatablesSampleApp', ['datatables']). ; 2. controller('SimpleCtrl', function ($scope, DTOptionsBuilder, DTColumnBuilder, $http) { ; 3. $scope.
Read more >
Datatables not initializing after reload operation in angular 7 app
i implemented the jquery.datatables in my Angular 7, i installed all the node modules and did the necessary configuration, and included the ...
Read more >
Cannot reinitialise DataTable - but it works!
I am currently integrating it into a Bootstrap 4 theme which initialises everything from an external minimised js file. Additional DataTables ...
Read more >
Using Angular DataTables to build feature-rich tables
The Angular DataTables library combines Angular directives with jQuery's DataTables plugin. See how to use it in our tutorial.
Read more >
Cannot reinitialise DataTable with Angular Datatable-angular.js
The above answer @Adrita Sharma was not working for me, it was throwing this error. core.js:9110 ERROR TypeError: Cannot read property 'dtInstance' of ......
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