Are you using server-side processing for your datatable? Because your link to the docs points to the server-side configuration for Datatables. Imho 1000 rows should be easily rendered by the client via "classic" Datatable-methods. Also the options pointed out on your linked page are for the server-side script to process the correct data for the table. That means, the length
value tells the server(!) how many rows he has to return. So your page have nothing to do with the "client-side" setup of the datatable.
So, to adjust the displayed number of rows on the "client-side" use the pageLength
value:
$(document).ready(function() {
$('#example').dataTable( {
"pageLength": 20
} );
} );
You can also adjust the lengthMenu
to setup the dropdown-selection where the user can specify how much rows he wants to see per page:
$(document).ready(function() {
$('#example').dataTable( {
"lengthMenu": [20, 40, 60, 80, 100],
"pageLength": 20
} );
} );
See a working demo here: http://jsfiddle.net/vf5wA/2/
EDIT:
I think your problem is, that you are returning the full set of items per each single request. As far as I know, Datatables works a little bit different. On your SQL-Statement you are setting a LIMIT to 1000, that means that 1000 rows will be returned by your api. But the Datatable gives you an parameter "iDisplayLength" which should be passed to your api via AJAX-Call. The number of items specified in "iDisplayLength" will then set the LIMIT for your SQL-Query.
E.g.:
AJAX-Call: https://api.example.com/datatable/something?iDisplayLength=50
And on your server, the "iDisplayLength"-Parameter will set the LIMIT for querying:
String sql = "SELECT UID,LastName,FirstName FROM employe LIMIT {iDisplayLength}";
object.put("iTotalRecords", {iDisplayLength});
I would try that, but I have never used server-side processing for Datatables, so this is just a shot in the dark.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…