In angular datatable, how to change the display of records in the options page

In the jquery data table, I can change the settings for writing to the page

"aLengthMenu": [[50, 100, 150, 200, -1], [50, 100, 150, 200, "All"]], 

Does 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 for http://l-lin.imtqy.com/angular-datatables/#/api but could not find

+7
source share
5 answers

You were close ... use the lengthMenu parameter and only one array:

 $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('order', [1, 'asc']).withOption('lengthMenu', [50, 100, 150, 200]) 
+11
source

I found the answer!

So, there is a variable that you use in a datatable called $scope.dtOptions and there is a way to add to this using .withOption('lengthMenu', [50, 100, 150, 200]);

Now, technically, this changed the length parameters, not the length, but in my case all I need to do is set the lowest length parameter for the length I want, and I actually 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]); 
+6
source
 $scope.dtOptions = DTOptionsBuilder.newOptions().withDisplayLength(10) // Default page size - 10,25,50,100 

You can customize your list with:

 $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('lengthMenu', [10, 25, 50, 100]) 
+1
source

If you have some data in the project and you want to add LengthMenu like everyone else, you can add it to the Run block

  app.run (['DTDefaultOptions', function (DTDefaultOptions) {
     DTDefaultOptions.setOption ('lengthMenu', [[10, 20, 25, 50, -1], [10, 20, 25, 50, 'All']]);
 }]);

If you want to add any option that is supported by jquery datatable, you can use

  DTDefaultOptions.setOption (key, value); 
0
source

Where does this line of code go in the project? I do not quite understand.

0
source

Source: https://habr.com/ru/post/989746/


All Articles