Hi,
I have a requirement for a grid that allows a user to update a record but they cannot create new ones. If my grid defines only the read and update action, when I save a record I get a 400 error returned but the save does go through. The 400 error is returned before the save action has completed. I have narrowed the issue down to the fact that I did not have a create action defined.
Why does a create action need to be defined even when there is no toolbar that allows them to add new records?
Simplified version of my grid definition:
@(Html.Kendo().Grid<TimeStudy.NetCore.Web.Models.TSCodeAssociationModel>()
.Name("gridTSCodeAssociation")
.HtmlAttributes(new { sender = "gridTSCodeAssociation", title = "TS Code Associaton" })
.Columns(c =>
{
c.Command(commands =>
{
commands.Edit().Text(" ").CancelText("Close").UpdateText("Save").HtmlAttributes(new { title = "Edit Association" }).IconClass("fas fa-pencil-alt fa-xs iconColor k-sm").UpdateIconClass("rcit-k-remove-icon-span").CancelIconClass("rcit-k-remove-icon-span");
}).ClientHeaderTemplate(TimeStudy.NetCore.Web.Common.ViewConstants.KENDO_REMOVE_FILTER_BTN).Width(55).Visible(@isEditor);
c.Bound(f => f.TSCodeAssociationId).Hidden();
c.Bound(f => f.Code).Width(50);
})
.Pageable()
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("EditTSCodeAssociation").Window(w => w.Title("Edit TS Code Association")))
.DataSource(dataSource =>
dataSource
.Ajax()
.Events(ex => ex.Error("function(e){gridWithSearchButton_onDataError(e, '#gridTSCodeAssociation')}"))
.Model(model =>
{
model.Id(f => f.TSCodeAssociationId);
})
.Read(read => read.Action("GridTSCodeAssociationAction", "TSCodeAssociation", new { method = "read" }).Data("kendoPageSearchParametersAntiForgery"))
.Update(read => read.Action("GridTSCodeAssociationAction", "TSCodeAssociation", new { method = "update" }).Data("kendoPageSearchParametersAntiForgery"))
//.Create(create => create.Action("GridTSCodeAssociationAction", "TSCodeAssociation", new { method = "create" }).Data("kendoSendAntiForgery"))
.PageSize(50)
)
.Events(e => e.DataBound("kendoGridLoadButtonReset_databound"))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.Contains("Contains")
))
)
.Scrollable(s => s.Height(600))
.Sortable()
.AutoBind(true)
.Deferred()
)
If I leave the create action commented out I get the 400 error message and I can see the network call shown in the attached image right before the grid update call.
version 2022.1.119