Inline Deletion using MVC3

Inline Deletion using MVC3

bighungrybighungry Posts: 2Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
Hello.

I have a working version of datatables in my MVC3 application. I am trying to implement inline deletion of records.

Here is what the script portion looks like:
[code]
@{

$(document).ready(function () {
var oTable;
oTable = $('#indexTable').dataTable({
"sDom": "<'row'<'span5'l><'span5'f>r>t<'row'<'span5'i><'span5'p>>",
"oLanguage": {
"sSearch": "Search all columns:",
"sProcessing": ""
},
"asStripeClasses": ['dataTableOddRow', 'dataTableEvenRow'],
"bJQueryUI": false,
"bAutoWidth": true,
"bPaginate": true,
"sPaginationType": "bootstrap",
"bProcessing": true,
"aoColumnDefs": [{ "bSortable": false, "aTargets": [3]}],
"aaSorting": [[1, 'asc']],
"fnDrawCallBack": function () {
alert('The Table has refreshed the data');
}
});
$('#indexTable a.delete').live('click', function (e) {
e.preventDefault();
$.ajax({
url: '/Audit/Delete/' + (this).id,
type: 'POST',
success: function () {
var nRow = $(this).parents('tr')[0];
oTable.fnDeleteRow(nRow);
alert('Record deleted');
},
error: function () {
alert('I could not delete this record').fadeIn();
}
});
});
$.extend($.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
});
$('#auditlog').addClass('active');
});

}
[/code]

What works:
1. The deletion is persisted to the database
2. The record is removed from the DOM

What does not work:
1. The record count does not update.

What I have tried:
1. oTable.fnDraw() and oTable.fnDraw(false). The first deletion works but on any subsequent deletion attempt I receive a [quote]Microsoft JScript runtime error: 'n[...]._aSortData' is null or not an object[/quote]
2. oTable.fnReloadAjax(). On the first attempt I receive [quote]DataTables warning: JSON data from server could not be parsed. This is cause by a JSON formatting error.[/quote]

Does anyone have any suggestions on what I am missing, or is what I am doing not the best way to achieve inline record deletion in MVC3?

Thanks.

Del
This discussion has been closed.