Reputation: 4974
im working with the datatables legacy to generate my dynamic table.
but in my sql i using offset rows to bring only 100 rows each time.
i try to use the pagination to get the number of the page and a dropdown to get the value of the rows to show on the page.
My problem is when i get my data via ajax i need to update the number of pages of the pagination.
For Example.
Total rows 57,
Showing rows 10,
Total pages 6,
i can´t find a why to update this information.
have somone any experience with that.
jquery code:
$("#status").DataTable({
"bPaginate": true,
"sPaginationType": "full_numbers",
"bLengthChange": true,
"aLengthMenu": [[5, 10, 15, 20], [5, 10, 15, 20]],
"iDisplayLength": 5,
"bFilter": true,
"bSort": true,
"aaSorting": [],
"bInfo": true,
"bAutoWidth": false,
"oLanguage": {
"sSearch": "Pesquisar:",
"oPaginate":
{
"sFirst": "<<",
"sPrevious": "<",
"sNext": ">",
"sLast": ">>",
},
}
})
Upvotes: 0
Views: 150
Reputation: 4918
I'm not sure if you're asking about sending the paging parameters to the server, or returning the paged record counts from the server to the client side.
If it's the former, then you need to use iDisplayLength and iDisplayStart which are passed to the server in the request. You don't say what server-side language you're using, but you need to get these values from the querystring and use them in your SQL query, something like:
Request.QueryString["iDisplayStart"]
If you're asking about returning the paging quantities from the server, then you return the values as iTotalRecords
and iTotalDisplayRecords
in the json:
return Json(new
{
param.sEcho,
iTotalRecords = rowCount,
iTotalDisplayRecords = rowCount,
aaData = result
}, JsonRequestBehavior.AllowGet);
See here for information about parameters passed in the datatables request and response.
Upvotes: 1