Hello,
I try setup my Kendo grid in a Net.Core project with inline editing, but the "Create" controller action not firing after I try add new row. The Read method executes successfully, but the Create method never executing.
My controller code:
[HttpPost] public ActionResult Create([DataSourceRequest] DataSourceRequest request, DynamicMessageViewModel product) { return Json(new[] { product }.ToDataSourceResult(request, ModelState)); } public ActionResult Read([DataSourceRequest]DataSourceRequest request) { IQueryable<DynamicMessageModel> dynamicmessagemodels = _context.DynamicMessage.DistinctBy(d => d.StringId).AsQueryable(); DataSourceResult result = dynamicmessagemodels.ToDataSourceResult(request, dynamicMessageModel => new DynamicMessageViewModel { Id = dynamicMessageModel.Id, StringId = dynamicMessageModel.StringId, Culture = dynamicMessageModel.Culture, Message = dynamicMessageModel.Message }); return Json(result); }
My view:
@(Html.Kendo().Grid<MyCoreSite.Models.DynamicMessage.DynamicMessageViewModel>() .Name("grid") .Columns(columns => { columns.Bound(c => c.Id).Hidden(); columns.Bound(c => c.StringId); columns.Bound(c => c.Culture).Hidden(); columns.Bound(c => c.Message).Hidden(); columns.Command(command => { command.Edit().Text(" ").CancelText(" ").UpdateText(" ").HtmlAttributes(new { title = Lang["Szerkesztés"].Value }); command.Destroy().Text(" ").HtmlAttributes(new { title = Lang["Törlés"].Value }); }).Width(102); }) .ToolBar(toolbar => { toolbar.Create(); toolbar.Excel(); }) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Pageable() .Selectable(selectable => { selectable.Mode(GridSelectionMode.Single); selectable.Type(GridSelectionType.Row); }) .Sortable(sortable => { sortable.SortMode(GridSortMode.SingleColumn); }) .Filterable(filterable => filterable.Mode(GridFilterMode.Row)) .Scrollable() .Events(events => { events.Edit("onEdit"); events.Change("onRowChange"); events.SaveChanges("onSaveChanges"); }) .DataSource(dataSource => dataSource .Ajax() .Create(create => create.Action("Create", "DynamicMessage")) .Update(update => update.Action("Update", "DynamicMessage")) .Read(read => read.Action("Read", "DynamicMessage")) ) )
My first question: why the Create action not firing after I try add new row? If I check the url of the Accept button, I see "#" in the href attribute...
My second question: after I click on the "Edit" button inside a row, the Cancel button appear. After I click on Cancel, the entire row will be removed from the grid. I dont understand why.
Thank you for help!
