angular-datatables `Cannot read property 'aDataSort' of undefined`

4.8k views Asked by At

Please help. I can't get my server-side datatable working.

When I add the .withOption('ajax', ...) to the options, it can't load anymore. I get the error: Cannot read property 'aDataSort' of undefined

This is my HTML:

<table id="myTable" datatable class="table table-striped" dt-options="options" width="100%">
<thead>
    <tr>
        <th>Col1</th>
        <th>Col2</th>
        <th><!--Col3--></th>
        <th><!--Col4--></th>
        <th>Col5</th>
        <th>Col6</th>
        <th>Col7</th>
        <th>Col8</th>
        <th>Col9</th>
    </tr>
</thead>

This is my JS in my controller:

$scope.options = DTOptionsBuilder.newOptions()
                .withOption('ajax', {
                    url: '/api/all',
                    processing: true,
                    type: 'POST',
                    dataSrc: 'data'
                })
                .withOption('processing', true)
                .withOption('serverSide', true)
                .withBootstrap()
                .withLanguageSource('lib/datatables/lang/Dutch.json')
                .withOption('searching', false);

EDIT - Also important to know that there has not been a AJAX call for the data.

Can somebody tell me what is going on??

0

There are 0 answers