JQuery Datatables - how to delete a newly added row?
I am looking at some legacy code where the user can add new rows to a datatables grid, click submit and they are saved on the database. When they are saved they are give a primary key each.
However the bug occurs BEFORE the rows are saved. The user decides to delete one of the newly added rows, but when he clicks save the rows added after the deleted row are NOT saved. So how do I fix it so that they are?
My table is defined as;
var oTable = $('#AjaxGrid').dataTable({ "sScrollY": 290, "bPaginate": false, "bLengthChange": false, "bFilter": false, "bSort": false, "bInfo": false, "bAutoWidth": false, "aoColumnDefs": [ { "sSortDataType": "dom-text", "aTargets": ["_all"] }, { "sType": "numeric", "aTargets": [-2] } ] });
and the delete code looks like
if (sumvalue > 0 && row.data('pkey') == 0) { $("#confirmdelete").dialog({ buttons: { "Delete Row": function () { // This code does not work. // This is where the user wants to delete a newly entered row that has not // been saved yet. row.remove(); totalRowCount--; $(this).dialog("close"); return; }, Cancel: function() { $(this).dialog("close"); } } }); $("#confirmdelete").dialog('open');