How does Pagination Work in Server Side Processing?

How does Pagination Work in Server Side Processing?

oneillgoneillg Posts: 5Questions: 2Answers: 0

Hi,
I'm new to datatables and I'm almost where I want to be just need to get over a hump. I have 500 records and am using server side processing to load a chunk at a time. All works fine the first time but the server code doesn't get called when I hit the next button. Would love a nudge in the right direction.

Here is the existing code. Thanks for any insight. -Gabe

$('#data-table').dataTable( {
"bProcessing": true,
"bServerSide": true,
"columns": [
{ "data": "first_name" },
{ "data": "last_name" },
{ "data": "company_name" },
{ "data": "phone1" },
{ "data": "phone2" },
{ "data": "email" }
],
"sAjaxSource": queryConst.QUERY_FILE,
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(returnData) {
fnCallback(returnData);
}
} );
},
} );

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 39,351Questions: 1Answers: 4,662 Site admin
    Answer ✓

    If you only have 500 records, I wouldn't bother with server-side processing. Only when you get to around 10k is it worth considering and only really required after 50k.

    Having said that, the server-side processing requirements are documented in the manual.

    I would also suggest you use ajax rather than the legacy sAjaxSource option.

    Allan

  • oneillgoneillg Posts: 5Questions: 2Answers: 0

    Thanks Allan. I was only using the 500 records as a test case, but your information is helpful. Are you saying it is OK to retrieve 40K records in one query memory wise?

  • allanallan Posts: 39,351Questions: 1Answers: 4,662 Site admin
    Answer ✓

    Depends on the server, the client computers, bandwidth and data complexity of course, but typically yes, less than 50k records should be okay.

    Allan

Sign In or Register to comment.