Keep in same page when updating table using ajax and pipelining
Keep in same page when updating table using ajax and pipelining
Hi, im using pipelining datatable option and everything works great. I have an interval that refresh the table, but the problem is that when I update the table it goes to the first page, and i want to stay in current page,
Im using this function to update table
$('#myTable').DataTable().clearPipeline().draw();
I need to do something like this
$('#myTable').DataTable().ajax.reload(null, false); that work when no using pipelining
$(document).ready(function(){
var table = $("#myTable").DataTable({
'processing': ajax_tables,
'serverSide': true,
'serverMethod': 'post',
'ajax': $.fn.dataTable.pipeline({
url:'load_users.php',
pages: 5,///number of pages to cache
}),
"columns": [
{"data": "id"},
{"data": "name"},
{"data": "lastname"}
],
"initComplete": function(){
setInterval(function(){
///Without pipeline this update table and keep in current page
///$('#myTable').DataTable().ajax.reload(null, false);
///I want to refresh table but stay in same page like option above
$('#myTable').DataTable().clearPipeline().draw();
}, 5000);
},
});
});
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
Answered here:
https://datatables.net/forums/discussion/comment/185149/#Comment_185149
Thanks a lot tangerine!!!! I was looking a lot but couldnt find the answer
This is the way i did it, hope it helps other people
$('#myTable').DataTable().clearPipeline().draw( false );