Limit Number of Rows
Limit Number of Rows
Mr Arslan Jawed
Posts: 9Questions: 6Answers: 1
Hello,
How can I limit the number of results in server side script.
Regards
This discussion has been closed.
Answers
Hi @Mr Arslan Jawed ,
The limitation should actually be done on the client-end, by
pageLength
. The protocol is discussed here. The client asks for a number of records, which the server is expected to return,Cheers,
Colin
Maybe I have the syntax wrong or don't understand.
When I add pageLength: 20, in my html file it seems to have no effect. I have a table of over 1000 records and wish to limit the total number of records returned (for performance) and also by a last modified field.
In an ordinary query I would do something like:
How would I accomplish this in datatables (in the html file or in the controller file with a where is fine)?
pageLength goes into your DataTables initialisation code.
Here the relevant excerpt from my initialization code:
Neither pageLength nor recordsTotal have any impact. Returns 1000+ records.
Doesn't look like you have enabled
serverSide
processing. If you want server side paging then you need to enable server side processing:This adds complications to your server code since it will be responsible for searching and order also. Please read the Server Side Processing docs for details. Also see this FAQ:
https://datatables.net/faqs/index#speed
It is recommended to use client side processing if possible. Which means all the rows are returned but the sorting and searching are done client side.
Kevin