Is there a reflow method for datatables?
Is there a reflow method for datatables?
![GMorris](https://secure.gravatar.com/avatar/a105ce0d21f61aa8f5046644bfae5d8a/?default=https%3A%2F%2Fvanillicon.com%2Fa105ce0d21f61aa8f5046644bfae5d8a_200.png&rating=g&size=120)
I would need to call a reflow method after deleting some stuff from a table.
function doDelete(id)
{
$.getJSON(window.location.origin+'/admin/reviews/delete/'+id,function(data){
if(data.error == 0){
$('tr[data-id="'+id+'"]').addClass('animated flash').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$('tr[data-id="'+id+'"]').hide().remove();
alertHandle('Review #'+id+' was deleted','success');
});
}else{
alertHandle(data.message,'error');
}
});
}
is there some function i can call on the datatables instance? i would like to redraw the datatable(ie update number of rows and pagination and such)
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
If you want to remove rows from the table you need to use the API - specifically
row().remove()
orrows().remove()
. Dropping them out using DOM methods doesn't work as DataTables doesn't know that you've deleted them using that method.If you need the animation, one option would be to call
row().remove()
in the callback once the row is hidden.Once all required rows have been removed, call
draw()
to redraw the table.Allan
nm. i see that the highlighted segments refer to the section in the manual. thanks. bout to give it a test run. looks like it should work
sweet, it works
Excellent - thanks for the feedback :-)
Allan