Reputation: 1909
I'm using jQuery DataTables and adding rows after a successful insert to a DB. How can I force a refresh of the table? I have checked on docs but found only how to refresh if data is loaded with Ajax. I'm adding to the tbody client side.
Upvotes: 1
Views: 1173
Reputation: 3551
If you are using legacy datatable
tableObj.fnClearTable();
tableObj.fnAddData(data);
tableObj.fnDraw();
also fnRedraw()
, If you want to redraw the table
If you are using new Datatable then this may help you.
var table = $('#example').DataTable();
$('#myFilter').on( 'keyup', function () {
table
.search( this.value )
.draw();
} );
var table = $('#example').DataTable();
// Sort by column 1 and then re-draw
table
.order( [[ 1, 'asc' ]] )
.draw( false );
Upvotes: 1