Selecting a row then clicking delete from the toolbar - it enters the ActionResult Remove but the passed data is blank - the ID is 0, rest of data is null. What is the issue?
Here is the view.
@(Html.EJ().Grid<Object>
("FlatGrid")
.Datasource(ds => ds.URL("GetData").UpdateURL("Update").RemoveURL("Remove").Adaptor(AdaptorType.UrlAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Normal); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("ID").HeaderText("ID").IsPrimaryKey(true).Visible(false).TextAlign(TextAlign.Left).Add();
col.Field("person_id").HeaderText("person_id").Visible(false).TextAlign(TextAlign.Left).Add();
col.Field("task_id").HeaderText("task_id").Visible(false).TextAlign(TextAlign.Left).Add();
col.Field("first_name").HeaderText("first_name").AllowEditing(false).TextAlign(TextAlign.Left).Type("string").Add();
col.Field("last_name").HeaderText("last_name").AllowEditing(false).TextAlign(TextAlign.Left).Type("string").Add();
col.Field("DOB").HeaderText("DOB").AllowEditing(false).TextAlign(TextAlign.Left).Type("datetime").Add();
col.Field("task_create_timestamp").HeaderText("task_create_timestamp").AllowEditing(false).TextAlign(TextAlign.Left).Type("datetime").Add();
col.Field("referral_acquired").EditType(EditingType.DropdownEdit).DataSource((IEnumerable<object>
)ViewBag.dropData).Width("12%").Add();
col.Field("auth_acquired").EditType(EditingType.DropdownEdit).DataSource((IEnumerable<object>
)ViewBag.dropData).Width("12%").Type("string").Add();
col.Field("handp_acquired").EditType(EditingType.DropdownEdit).DataSource((IEnumerable<object>
)ViewBag.dropData).Width("12%").Type("string").Add();
col.Field("ascan_acquired").EditType(EditingType.DropdownEdit).DataSource((IEnumerable<object>
)ViewBag.dropData).Width("12%").Type("string").Add();
col.Field("other_acquired").EditType(EditingType.DropdownEdit).DataSource((IEnumerable<object>
)ViewBag.dropData).Width("12%").Type("string").Add();
})
.ClientSideEvents(eve => { eve.QueryCellInfo("querycellinfo"); eve.RowSelected("onRowSelected"); } )
)
Here is the controller:
public ActionResult Remove(NextGenTask value) //the value param only contains a entity with values that only appear in grid (the rest are null), NOT the original entity with updated values.
{
NextGenTask req = db.NextGenTasks.Single(o => o.ID == value.ID);
db.Entry(req).State = EntityState.Deleted;
//req.BU = value.BU;
try
{
db.SaveChanges();
}
catch (Exception ex)
{
throw;
}
var result = db.NextGenTasks.ToList();
return Json(new { result = result, count = result.Count }, JsonRequestBehavior.AllowGet);
}