Cannot read property 'aDataSort' of undefined in agnular js datatables
See original GitHub issueHello everyone, I am trying to implement angular-datatables in my project but it returns "TypeError: Cannot read property ‘aDataSort’ of undefined**"
I am using Angular js version 1.4.9. Jquery version 2.1.1 DataTable version 1.10.10
Refrence site http://l-lin.github.io/angular-datatables/ Below is my code
Html
<div class="col-md-12" ng-controller="WithAjaxCtrl as showCase"> <table datatable="" dt-options="showCase.dtOptions" dt-columns="showCase.dtColumns" class="row-border hover"></table></div>
Angular js controller
`angular.module( 'admin.package', [
'ui.router',
'ui.bootstrap',
'datatables',
'datatables.bootstrap',
'ngResource',
'plusOne'
]).controller('WithAjaxCtrl', WithAjaxCtrl);
function` WithAjaxCtrl(DTOptionsBuilder, DTColumnBuilder,$http,UserService,localStorageService) {
UserService.obj.get('packages/index',localStorageService.get('userkey').token).then(function (results) {
if(results.status==200){
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromSource(results.data.packages)
.withPaginationType('full_numbers');
vm.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('id'),
DTColumnBuilder.newColumn('package_name').withTitle('Packag Name'),
DTColumnBuilder.newColumn('amount').withTitle('Amount'),
DTColumnBuilder.newColumn('package_duration').withTitle('Amount'),
DTColumnBuilder.newColumn('currency').withTitle('validity')
];
console.log(vm.dtColumns);
console.log( vm.dtOptions);
}else{
alert('You are not a authorized user');
}
}, function(reason) {
console.log(reason);
});
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
JQuery Datatables : Cannot read property 'aDataSort' of ...
Most of the time it occurs when something is undefined. I copied the code and removed few columns which disturbed the order by...
Read more >Cannot read property 'aDataSort' of undefined - DataTables
Dear DataTables I get the following error Cannot read property 'aDataSort' of undefined. Is there anything I am missing ?
Read more >TypeError: Cannot read property 'aDataSort' of undefined #122
Hi,. I get the same error and I'm using angular 1.3.8, and the last version of datatables. I'm rendering my table ...
Read more >Cannot read property 'aDataSort' of undefined - YouTube
JavaScript : JQuery Datatables : Cannot read property ' aDataSort' of undefined [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
http://l-lin.github.io/angular-datatables/#/bindAngularDirective
Your table is rendered after you fetch the data. Thus, your table do not have any options, that’s why DataTables is throwing such error. Since you are rendering in two steps (one request to the server, then render the table), you need to tell the table not to render before the data is fetched. You can use the
ngIf
to do that: