Pagination jumps to first page if redraw table using fnClearTable occured in other pages.
Pagination jumps to first page if redraw table using fnClearTable occured in other pages.
shreyanshu
Posts: 1Questions: 1Answers: 0
I created a table and get the data of the tables from server side using ajax. Here's my code:
var runDataTable_example1 = function() {
var oTable = $('#sample_1').dataTable({
"aoColumnDefs" : [{
"aTargets" : [0]
}],
"oLanguage" : {
"sLengthMenu" : "Show _MENU_ Rows",
},
"aaSorting" : [[0, 'desc']],
"aLengthMenu" : [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"] // change per page values here
],
// set the initial value
"iDisplayLength" : 10,
"bFilter": false,
"pagingType": "full_numbers",
"processing": true,
"serverSide": true,
"ajax": "myjobData.php",
});
//$('#sample_1_wrapper .dataTables_filter input').addClass("form-control input-sm").attr("placeholder", "Search");
// modify table search input
$('#sample_1_wrapper .dataTables_length select').addClass("m-wrap small");
// modify table per page dropdown
$('#sample_1_wrapper .dataTables_length select').select2();
// initialzie select2 dropdown
$('#sample_1_column_toggler input[type="checkbox"]').change(function() {
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var iCol = parseInt($(this).attr("data-column"));
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis(iCol, ( bVis ? false : true));
});
};
I set an interval of 10 seconds so that table could refresh using this code:
window.setInterval(function(){
var oTable = $("#sample_1").dataTable();
oTable.fnClearTable();
},10000);
But if I am page number 3 and after 10 seconds the data refresh and jumps to page number 1.
How can i avoid it to jump to page number 1 and stay in page 3 even after refresh.
Thanks in advance.
This discussion has been closed.