Problem with DTOptionsBuilder
Hi !
I have the code below in my project :
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withPaginationType(2)
.withOption('order', [0, 'desc']);
The withPaginationType and withPaginationType are working good. However the withOption('order', [0, 'desc']) is not working . And i don't know what happen with my code, i cannot fix it. Could you give me some advice ?
I just tried out .withOption('order', [1, 'desc']) and .withOption('order', [[1, 'desc']]) and both worked fine on my end. I'm using the latest minified js file available from the master branch.
It may be necessary to see more code. I tried this two ways:
// Method 1
$scope.dtOptions = {
ajaxSource: 'my/ajax/source',
serverSide: true,
pagingType: 'full_numbers',
order: [[1, 'desc']]
}
// Method 2
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajaxSource', 'my/ajax/source')
.withOption('serverSide', true)
.withOption('pagingType', 'full_numbers')
.withOption('order', [1, desc])
Again, both worked perfectly fine for me.
I should add, I am not using The Angular Way. My table (since I'm using a server-side AJAX source) is built like so:
<table datatable dt-options="dtOptions" dt-columns="dtColumns"
class="table table-bordered table-hover table-striped" id="dtTable">
</table>
What version of DataTables are you using? If it's 1.9.4, then the key value for order should be aaSorting and not order (which is for 1.10+).
aaSorting fixed my problem! I also needed to use .withOption('order', [[1, desc]]) with double brackets, not single [ ]. Thanks!
By the way, I am using the Angular way, and it works great now.
etst