Grid with update but no create

1 Answer 197 Views
Grid
Rick
Top achievements
Rank 1
Rick asked on 04 Mar 2022, 05:50 PM

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

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 09 Mar 2022, 10:57 AM

Hi Richard,

Based on the provided information, I suspect that the call is performed outside of the grid. This is because I could not see any endpoints that are called timestudy. I suspect that there might be an event handler or any generic JS logic that might be triggering the call. 

Is it possible for you to isolate the problem in a sample and send it back to me so that I can investigate it? I would recommend that you perform a global search for the timestudy keyword and see all the places that is used. After that track what invokes this function.

 

Regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or