Remove a row the table without asking the user for confirmation

Remove a row the table without asking the user for confirmation

Aaron MatengaAaron Matenga Posts: 1Questions: 1Answers: 0

I have some code in the 'preSubmit' event that checks if there is already an existing row with the same email as the row that is currently being added. If the email does already exist, I want to delete the existing row. The following code will work for me:

editor.remove(table.row(i)).submit();

where table.row(i) is the row containing the duplicate email

The problem is that I don't want the user to have to confirm the delete, but when I try the following code (adding false as a second parameter) it doesn't ask for confirmation but it also doesn't delete the row:

editor.remove(table.row(i), false).submit();

also tried this code without the "submit()" at the end, didn't make a difference

Is this a bug?

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    editor.remove(table.row(i), false).submit();

    Try using table.row(i).index().

    In this example if I run:

    var rowIdx = $('#example').DataTable().row(':eq(0)').index();
    editor.remove(rowIdx, false).submit();
    

    It deletes the first row without confirmation.

    Allan

This discussion has been closed.