Reputation: 2004
I am working with JQuery DataTable
and fetching data from server and it is working fine except of Pagination. when I click next it fetches next result but when I click previous then also it returns next result not previous. I have debugged the code and found that sEcho is getting incremented by one each time. Also whenever I redraw Table it send request on server and fetching next result.
my code is for updating sEcho
:
sEcho = request.getParameter("sEcho");
What is wrong not getting.
My DataTable code is
$lmTable = $('#datatable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": url,
"iDisplayLength": 10,
"bFilter":true,
"bSort": false,
});
Upvotes: 0
Views: 5367
Reputation: 1274
on every request to the server, the value of sEcho
is updated and sent to the server.
i.e. on Next
, Previous
button clicks too.
This sEcho
acts like a token to make a reference with the returned values.
So while returning the array via the url
, make sure the same sEcho
value is retuned.
Eg: Form data
sEcho:1
iColumns:7
sColumns:
.....
Returned values should be like -
{"sEcho":1,"iTotalRecords":3,"iTotalDisplayRecords":3 ......
The sEcho
sent and sEcho
received should be same. Next time may be 2
is sent, so 2
should be received.
I hope it helps someone.
Upvotes: 2