Server Side Pagination (not working)

Server Side Pagination (not working)

faixanfaixan Posts: 3Questions: 2Answers: 0

I am facing problem when trying to implement server side pagination . I am calling public rest API , but the problem is data retrieves without pagination in once.
I want data should be retrieved in chunks of 10, and when click next button it should again get 10 records in the response.

<

script type="text/javascript" >
$(document).ready(function() {
$('#testing-data-table').dataTable({
"processing": true,
"serverSide": true,
paging: true,
"ajax" : {url : "https://jsonplaceholder.typicode.com/posts",
dataSrc: ''
},
"columns" : [
{ "data" : "userId"},
{ "data" : "id"},
{ "data" : "title"},
{ "data" : "body"}
]
});
});

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    you get all of the data because your target returns all of the data because there is nothing in the target url that controls what data is being set back.

    serverside paging is controlled by the server, not data tables.

    DataTables sends an object to the server and that is used to determine what to send back.

    this page describes what is sent to the server and how your data should be sent back

    https://datatables.net/manual/server-side

  • faixanfaixan Posts: 3Questions: 2Answers: 0

    Thanks.
    Moreover , I will write java code as a server side, so first my datatable's ajax property will have the path of my java class, then from java class I should be calling the web service and then filtering it out ? right ?

This discussion has been closed.