angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

Problem with DTOptionsBuilder

Open heavyrajn opened this issue 12 years ago • 6 comments

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 ?

heavyrajn avatar Jul 23 '14 04:07 heavyrajn

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.

prateem avatar Jul 23 '14 05:07 prateem

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>

prateem avatar Jul 23 '14 05:07 prateem

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+).

l-lin avatar Jul 23 '14 07:07 l-lin

aaSorting fixed my problem! I also needed to use .withOption('order', [[1, desc]]) with double brackets, not single [ ]. Thanks!

greghaar avatar Jul 24 '14 03:07 greghaar

By the way, I am using the Angular way, and it works great now.

greghaar avatar Jul 24 '14 03:07 greghaar

etst

millionairetai avatar Aug 28 '15 11:08 millionairetai