How to display the last inserted value in the database when datatable is reloaded
How to display the last inserted value in the database when datatable is reloaded

whenever datatable is refreshed/reloaded with json data, how would i display the last inserted data in the database,
http://prntscr.com/lbngn8
here is my code:
`$(document).ready(function() {
renderTable('criticalmount');
});
function renderTable(element_id1){
$(`#${element_id1}`).DataTable.ext.pager.numbers_length = 4;// For setting pagination with elipses(...)
var t2= $(`#${element_id1}`).DataTable( {
"lengthMenu": [[4, 8, 12, -1], [4, 8, 12, "All"]],
autoWidth:true,
paging: true,
"pagingType": "full_numbers",
"processing": true,
serverSide: true,
"ajax":{ url:"../mount_point_ajax/serverSide.php",
// "type": "POST" },
});
setInterval( function () {
t2.ajax.reload(false,false);//pagination kept as false
}, 3000 );
}`
everytime the data inserted into the database gets added to the last record of datatable, I want to display every new record at the begining
Thanks
Koka
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @vaishnavkoka ,
Would changing the ordering on that first column help? If you sorted desc,
order
, then the most recent would always be at the top.Cheers,
Colin
Hi @colin ,
Thanks it helped me upto an extent.
Regards
Koka