I've implemented the above and it is sortof working. Here is the behavior I'm experiencing:
1. create a new grid record.
2. click the custom delete button. (record removed from grid but delete controller not run)
3. refresh page (record re-appears in the grid)
4. click the custom delete button again. (delete controller runs and deletes the record)
Should I be doing something after create of new record?
Create controller looks like this:
public ActionResult ElectionLocationCreate([DataSourceRequest]DataSourceRequest request, ElectionLocations model, int id)
{
if (ModelState.IsValid)
{
var el = new ElectionLocation();
el.ElectionControlID = id;
CopyElectionLocationModelToElectionLocation(model, el);
el.CreatedBy = HttpContext.User.Identity.Name;
el.CreatedDate = DateTime.Now;
db.ElectionLocations.Add(el);
db.SaveChanges();
//return RedirectToAction("Index");
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
//model.IsNew = true;
return View(model);
}