What and where Iam doing wrong with server side pagination

What and where Iam doing wrong with server side pagination

bluesapphirebluesapphire Posts: 17Questions: 0Answers: 0
edited February 2011 in General
First of all, sorry for not showing live fault, because of no access to web hosting account currently.

My problem is that, every configuration is working except server side pagination.

I have following query string from client :
[code]http://localhost/main/user/view?sEcho=1&iColumns=6&sColumns=&iDisplayStart=0&iDisplayLength=10&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&sSearch_2=&bRegex_2=false&bSearchable_2=true&sSearch_3=&bRegex_3=false&bSearchable_3=true&sSearch_4=&bRegex_4=false&bSearchable_4=true&sSearch_5=&bRegex_5=false&bSearchable_5=true&iSortingCols=1&iSortCol_0=0&sSortDir_0=asc&bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true&bSortable_4=true&bSortable_5=true[/code]

After sending this query string, I receive following respnse from server:
[code]{"iTotalRecords":"102","iTotalDisplayRecords":"25","aaData":[{"member_id":"1","last_name":"Solow","first_name":"Jeanne"},{"member_id":"2","last_name":"Lundsten","first_name":"August"},{"member_id":"3","last_name":"Erdmann","first_name":"Kay"},{"member_id":"4","last_name":"Arbogast","first_name":"Ruth"},{"member_id":"5","last_name":"Dorfman","first_name":"Carol"},{"member_id":"6","last_name":"Eliason","first_name":"Jessica"},{"member_id":"7","last_name":"Sawyer","first_name":"Dennis"},{"member_id":"8","last_name":"Phillips","first_name":"Donald"},{"member_id":"9","last_name":"Anderson","first_name":"Marcia"},{"member_id":"10","last_name":"Kilgore","first_name":"Leonard"},{"member_id":"11","last_name":"Lederman","first_name":"Judith"},{"member_id":"12","last_name":"Bodell","first_name":"Bonnie"},{"member_id":"13","last_name":"Reusch","first_name":"Diane"},{"member_id":"14","last_name":"Hilby","first_name":"Bernard"},{"member_id":"15","last_name":"Propper","first_name":"Harvey"},{"member_id":"16","last_name":"Michaels","first_name":"Amanda"},{"member_id":"17","last_name":"Hagler","first_name":"Carolyn"},{"member_id":"18","last_name":"York","first_name":"Mark"},{"member_id":"19","last_name":"Feit","first_name":"Daniel"},{"member_id":"20","last_name":"Overland","first_name":"Roland"},{"member_id":"21","last_name":"Lacke","first_name":"Bruce"},{"member_id":"22","last_name":"Hurst","first_name":"Sally"},{"member_id":"23","last_name":"Pitas","first_name":"Clifton"},{"member_id":"24","last_name":"Wheeler","first_name":"Mae"},{"member_id":"25","last_name":"Nelson","first_name":"Anthony"}],"sEcho":"1"}[/code]

And following is my datatable configuration code:
[code]
if( typeof dataTable == 'undefined' )
dataTable = jQuery( '#records').dataTable({
"bAutoWidth" : false, "bPaginate" : true,
"bStateSave" : true,
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": readUrl,
"sPaginationType": "full_numbers",
"fnServerData": function(sSource, aoData, fnCallback){
jQuery.ajax({
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": function(responseText){
response = responseText.aaData;
jQuery( '#records > tbody' ).html( '' );
jQuery('#readTemplate').render( response ).appendTo( "#records > tbody" );
} /* End Of success function */
});
},
});
[/code]


The web page shows all records, at once, without any pagination. Can some one guide me what and where Iam doing wrong with server side pagination.

Thanks in advance

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    iTotalDisplayRecords and iTotalRecords should be the same - unless you have a filter applied. That will be what's doing in the pagination: http://datatables.net/usage/server-side

    Allan
  • bluesapphirebluesapphire Posts: 17Questions: 0Answers: 0
    I had tried with this also, but pagination is disabled in all types of situations.

    [code]"iTotalRecords":"102","iTotalDisplayRecords":"102"[/code]

    The result is same and fault continues.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Have a look at this example: http://datatables.net/examples/server_side/custom_vars.html . You need to make use of fnCallback rather than manipulating the DOM manually.

    Allan
This discussion has been closed.