Issue with data table pagination with the server side programming

Issue with data table pagination with the server side programming

SriramTSriramT Posts: 2Questions: 0Answers: 0
edited December 2013 in DataTables 1.9
Hi All,
I am a novice to the data tables. In my company I have a requirement for pagination on the data tables from the server side and apart from displaying the results I need to display the check box and the link to the YYYNbr.

The approach I am following is

I am calling the Ajax call first and trying to append the results to the data table. For each click on the data table (like sorting, default page size, page numbers ), the data base is queried and the results are displayed based on the action performed.

the code in .js file is like this

when the search button is clicked this is the function called.

function searchCriteria(){

$.ajax({
type : "GET",
contentType : 'application/json',
async: "false",
data : $('#MODELATTRIBUTE').serialize(),
url : "Results",
success : function(response) {
if (response.errorCode == 0) {
$("#DDD").empty();
var list = response.RESULTLIST;

var totalRecords = response.totalRecords;

$
.each(
list ,
function(key, value) {

var tableRow = ""+value.YYYNbr+""
+ value.YYYNbr

+ ">";

$("").html(tableRow)
.appendTo("#DDD");
}
});


genericCalls(totalRecords, response.list);

}
},
});
}
}

function genericCalls(totalRecords, list){
var oTable = $('#example').dataTable({"bPaginate": true, "sPaginationType": "full_numbers", "bFilter" : false,
"bInfo":true,"iDeferLoading": totalRecords,"bServerSide": true,"sAjaxSource": "{{ajax funtion}}", "iTotalRecords":totalRecords
});

oTable.fnAddData(list);
}

only first time the page is set like(by default 10 records are set and the number of pages are 5 for 62 records displayed) and aftert that wven when I change the page size to 25 or 50 or 100, the results are displayed but the page size drop down is getting reset to 10 and pagination is not working. Any help in this regard will be highly appreciated.

Please contact me if you need more information.

Thanks,
Sriram.T

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Please link to a test case showing the issue: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
This discussion has been closed.