When setting pageLength
property in DataTables
, the data is divided into multiple pages.
However, when DataTables.scroller
plugin is applied, the pageLength
setting is ignored and all data is displayed on one page.
How can I enable the pageLength
setting while applying the scroller
plugin?
Scroller: 2.0.7
2
Answers
As answered above, pagination and scroller can be combined without any complex settings.
After some investigation, I found what was happening to my environment.
In my system, DataTable has to hide the
lengthChange
select box.Until the scroller plugin was applied, the
pageLength
setting had been reflected in the DataTable as expected.However, when I applied scroller, the DataTable became to show all records instead of the count set as
pageLength
value.I didn't realize the
pageLength
settings were reset because thelengthChange
select box is hidden.(For the investigation purpose, I created the simplified DataTable, but I could not find the 'trap' of the scroller specification, then I still suspected it was the restriction of the plugin.)
Now I understand the
pageLength
setting will be just ignored whenscroller
istrue
.If
pageLength
andscroller
is used together, thepageLength
value is just needed to set programmatically.That's simple.
[FYI] Simplified code is shown below:
The behavior can be checked by switching the
scroller
setting to true or false.Its possible to combine pagination and scroller :
by adding this options :