I'm trying to add a new record using GridEditMode.PopUp, but my methods are called incorrectly and sometimes not called at all.
My grid is declared like this:
With the Create method like this:
When I try to debug it, the code in the CreateAdhocTask method is not called consequtively. Instead the debugger jumps up and down between the lines until it finally reaches the last }
Debugging it again makes it jump around again, but in a different order. It seems to have a mind of it's own. It's working fine for the Read method.
More confusing is that it also calls the CreateAdhocTask method for the Update method, although a different method is supposed to be called there.
Also, the DestroyAdhocTask is completely ignored.
What would cause this?
My grid is declared like this:
@(Html.Kendo().Grid<DigiBob.AppServices.ViewModels.Governance.Duties.AdhocTaskViewModel>() .Name("Grid") .Columns(columns => { columns.Bound(p => p.ShortDescription).Width(50); columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160); }) .ToolBar(toolbar => { toolbar.Create(); }) .Editable(ed=>ed.Mode(GridEditMode.PopUp).TemplateName("AdhocTask")) .Pageable() .Sortable() .Scrollable() .Filterable() .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Events(events => events.Error("error_handler")) .Model(model => model.Id(c => c.ID)) .Create(update => update.Action("CreateAdhocTask", "Home")) .Read(read => read.Action("GetAllAdhocTasks", "Home")) .Update(update => update.Action("UpdateAdhocTask", "Home")) .Destroy(update => update.Action("DestroyAdhocTask", "Home")) ) )[AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateAdhocTask([DataSourceRequest] DataSourceRequest request, AdhocTaskViewModel item) { if (item != null && ModelState.IsValid) { _adhocTaskRepository = new AdhocTaskRepository(_context); AdhocTask target = new AdhocTask(); target.ShortDescription = item.ShortDescription; _adhocTaskRepository.Insert(target); _adhocTaskRepository.Save(); item.ID = target.ID; } return Json(new[] { item }.ToDataSourceResult(request, ModelState)); }Debugging it again makes it jump around again, but in a different order. It seems to have a mind of it's own. It's working fine for the Read method.
More confusing is that it also calls the CreateAdhocTask method for the Update method, although a different method is supposed to be called there.
Also, the DestroyAdhocTask is completely ignored.
What would cause this?