Issue with data table pagination with the server side programming
Issue with data table pagination with the server side programming
SriramT
Posts: 2Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
Allan