Remove Row Datatable by ID

Asked

Viewed 1,357 times

3

Is it possible to remove a line from the datatable by id? It’s that I have a confirmation modal asking if the user wants to delete. If you click yes, it calls a delete function.

$('#confirm-delete').on('show.bs.modal', function(e) {
    var data = $(e.relatedTarget).data();
    $('.btn-ok', this).data('recordId', data.recordId);
    $('#message_confirm_delete').html(data.message);
});
$('#confirm-delete').on('click', '.btn-ok', function(e) {
    var id = $(this).data('recordId');
    $('#confirm-delete').modal('hide');
    $.deleta2(id);
});
$.deleta2 = function (id) {
    var data_table = $('#dataTables-example').DataTable();
    console.log(data_table);
};

1 answer

1


This solved...

var data_table = $('#dataTables-example').DataTable();
data_table.row($('#item_'+id)).remove().draw();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.