Resetting iDisplayStart to 0 after deleting only row on last page

Resetting iDisplayStart to 0 after deleting only row on last page

Steve WarinSteve Warin Posts: 1Questions: 0Answers: 0
edited April 2011 in General
Apologies in advance - I'm a bit of a newbie to DataTables.

After deleting the last row in the last page of a table, the table is redisplayed showing e.g. "No matching records found" and "Showing 31 to 30 of 30 entries". What I would like to do is reset iDisplayStart to 0 after deleting a row so that page 1 is displayed. I'm wondering if this is possible, and if so what code do I use, and where do I put it.

I am using ASP.Net, MVC framework 2, C#

Below is my table initialisation code:

[code]
$(document).ready(function() {

var oTable = $('#example').dataTable({
"bServerSide": true,
"sAjaxSource": "/Home/AjaxHandler",
"bProcessing": true,
"bStateSave": true,
"aLengthMenu": [[5, 10, 20, 50, -1], [5, 10, 20, 50, "All"]],
"iDisplayLength": 20,
"sPaginationType": "full_numbers",
"bInfo": true,
"aaSorting": [[1, "asc"]],
"aoColumns": [
{ "sName": "Action",
"bSearchable": false,
"bSortable": false,
"fnRender": function(oObj) {
return 'View' +
' Delete';
}
},
{ "sName": "Term" },
{ "sName": "Abbreviation" },
{ "sName": "Keywords",
"bSearchable": false,
"bSortable": false
}
],
"aoColumnDefs": [
{ "sWidth": "10%", "aTargets": [0] },
{ "sWidth": "40%", "aTargets": [1] },
{ "sWidth": "20%", "aTargets": [2] },
{ "sWidth": "30%", "aTargets": [3] }
]

});
});
[/code]


Below is the relevant code snippet from the AjaxHandler method in my controller class:

[code]
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = allTerms.Count(),
iTotalDisplayRecords = filteredTerms.Count(),
iDisplayStart = (lRecordJustDeleted == true ? 0 : param.iDisplayStart),
aaData = result
},
JsonRequestBehavior.AllowGet);
[/code]

The code line "iDisplayStart = (lRecordJustDeleted == true ? 0 : param.iDisplayStart)" seems to have no effect.

Can anyone advise on this?
This discussion has been closed.