I found this very cool Angular Datatable library which adds pagination, search and stuff to the table. I works well with predefined table headers but I need to paginate a table who's headers ain't predefined.
I tried following this example on their official documentation, with a few changes of my own, but it gave me this error:
DataTables warning: table id=DataTables_Table_0 - Ajax error. For more information about this error, please see http://datatables.net/tn/7
This is how I tried it:
in my html file
<table datatable="" dt-options="dtOptions" dt-columns="dtColumns" class="row-border hover"></table>
in my controller
angular.module("app").controller("uploadDataController", ['$scope',
'DTOptionsBuilder', 'DTColumnBuilder',
function($scope, DTOptionsBuilder, DTColumnBuilder) {
SetupScreen();
function SetupScreen() {
$scope.dtOptions = DTOptionsBuilder.fromSource('data.json')
.withPaginationType('full_numbers');
$scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID'),
DTColumnBuilder.newColumn('firstName').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name').notVisible()
];
}
}
I'm receiving data from server that can contain any kind of headers so I cannot define the columns.
any ideas?