I've done a row remove() and then I tried to fnDestroy() and initialize back the DataTable. The record count and the pagination does not effected(The *DataTable not refreshed)*.
I've also tried to use fnDraw() but it's still no use.
I've looked at the page source and the deleted row html is still there.
I'm using Ajax to delete the row. Appreciate your help
This is my delete script:
$(document).ready(function()
{
$('table#sample_1 td a.delete').click(function()
{
if (confirm("Are you sure you want to delete this row?"))
{
var id = $(this).parent().parent().attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: "process.php",
dataType: "json",
data: data,
cache: false,
success: function()
{
var dtable = $('#sample_1').dataTable();
dtable.fnDestroy();
parent.fadeOut('slow', function() {$(this).remove();});
//Reinitialize the datatable
$('#sample_1').dataTable({
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page",
"oPaginate": {
"sPrevious": "Prev",
"sNext": "Next"
}
},
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [0]
}]
});
}
});
}
});
});
</script>
You can use fnDeleteRow to delete a row in the datatable. This function will automatically redraw the table.
Refer this, http://datatables.net/api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With