Remove Row DataTable by ID

2

Is it possible to remove a row from the datatable by id? I have a confirmation mode 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);
};
    
asked by anonymous 26.08.2016 / 15:27

1 answer

1

This solved ...

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