JQuery datatables, programmatically change the number of rows displayed

Is there a way to programmatically change the number of rows displayed without having to manually select from the drop-down list?

I know how to change the default number of rows. When the table first loads, I want it to load all the rows, and then β€œrefresh” the table to display only the first 10 rows. But I want to update the programmitcally table instead of choosing a number from the drop-down list.

My problem is that if the default number of lines is less than the total number of lines, then when hidden lines are displayed after changing the number of the drop-down list or by swapping through the lines, these lines do not have all css and js, which I attributed to all the lines. For some reason, only the lines shown by default have all the functionality, and the lines shown later do not work.

I believe that the easiest way to fix this with the least amount of code is to simply load all the lines by default, and then programmatically change the number of lines shown only to display the first 10 or so.

Thanks for any help.

+5
source share
2 answers

First you have to set datatables as a variable:

var oTable = $('#some_selector').dataTable({
    //some properties
})

" ":

var oSettings = oTable.fnSettings();
oSettings._iDisplayLength = 5;

:

oTable.fnDraw();
+5

, , DT. displayLength 20 :

table.context["0"]._iDisplayLength = "20";
table.draw();

datatables 1.10.10

0

All Articles