How to make server call on clicking of page indexes ( clicking on numbers or previous or next )

How to make server call on clicking of page indexes ( clicking on numbers or previous or next )

TanveerTanveer Posts: 2Questions: 1Answers: 0

below is the config I have ,
dt = tableid.DataTable({
"initComplete": processTable,
"bDestroy": true,
jQueryUI: true,
"sDom": '<"top"lf>rt<"bottom"ip><"clear">',
// "aaData": tbldata,
"aoColumns": col,
"bServerSide": true,
"sAjaxSource": "/App/home/loadDetails",
"bProcessing": true,
"ordering": true,
"searching": true,
"destroy": true,
"columnDefs": colheader
});

Problem statement : If I'm getting 100 records from database , 10 of 100 records I have sent to UI as response . When user clicks on Next button or User clicks on the page index ( i.e 1,2, 3 ...etc ) then I have to make a server call and get the 11th 20th record from out of 100 records.

Help will really appreciated .

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    Change serverSide to false and get all 100 records. Let DataTables manage it.

    dt = tableid.DataTable({
    "initComplete": processTable,
    "destroy": true,

    "sDom": '<"top"lf>rt<"bottom"ip><"clear">',

    "columns": col,
    "serverSide": false,
    "sAjaxSource": "/App/home/loadDetails",

    "ordering": true,
    "searching": true,

    "columnDefs": colheader
    });

  • TanveerTanveer Posts: 2Questions: 1Answers: 0

    The reasons I want to send only 10 records to UI is, I'm having server side operation's on those records then I have to send it to UI, If I go on processing all 100 records response time and data consume time will be more...

    This is the reason I'm expecting to have server call on each click, I hope you got it.

This discussion has been closed.