In jquery data table I can change records per page option by
"aLengthMenu": [[50, 100, 150, 200, -1],
[50, 100, 150, 200, "All"]],
Anyone know how to achieve this in angular?
I tried
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('order', [1, 'asc']).withDisplayLength(250);
and
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('order', [1, 'asc']).withOption('LengthMenu', [[50, 100, 150, 200, -1], [50, 100, 150, 200, "All"]])
I want to show 50, 100, 150, 200
I searched at http://l-lin.github.io/angular-datatables/#/api but couldn't found
You were close... use 'lengthMenu' option and only one array:
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('order', [1, 'asc']).withOption('lengthMenu', [50, 100, 150, 200])
I found the answer!
So there is a variable you use in the datatable called $scope.dtOptions
and there is a way to add on to that with .withOption('lengthMenu', [50, 100, 150, 200]);
Now, technically that changed the length options not the length, but in my case all I need is to set the lowest length option to the length I want, and I effectively changed the default length of the table.
Example:
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withDOM('<"html5buttons"B>lTfgitp')
.withButtons([])
.withOption('order', [1, 'asc'])
.withOption('lengthMenu', [50, 100, 150, 200]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With