MVC Grid PopEdit Multiple calls to Insert Action on Update Button click

5 posts, 0 answers
  1. Patrick
    Patrick avatar
    30 posts
    Member since:
    Jan 2018

    Posted 06 Feb 2018 Link to this post

    I have a grid  with a create tool bar.

    .ToolBar(toolbar => toolbar.Create().Text("Add new Inspection"))

     

    My grid is set to editable with a template.

    .Editable(editable => editable.Mode(GridEditMode.PopUp).Window(w => w.Width(600)).TemplateName("Inspection"))

     

    My data source is pretty standard.

    .DataSource(dataSource => dataSource
            .Ajax()
                .Model(model => model.Id(Inspection => Inspection.DEPInspectionsID))
                .Read(read => read.Action("InspectionItems_Read", "Inspections"))
                .Create(create => create.Action("InspectionItem_Create", "Inspections"))
                .Update(update => update.Action("InspectionItem_Update", "Inspections"))
                .Destroy(destroy => destroy.Action("Inspections_Destroy", "Inspections"))
            )

     

    When I click on the standard Update button on the pop up it calls the InspectionItem_Create action once for the new record, but then it also calls it again for each of the other records on the list as well...

    Why would a single click of the update button trigger the function for not only for the item created using the model... but for all of the additional items in the list?

     

  2. Patrick
    Patrick avatar
    30 posts
    Member since:
    Jan 2018

    Posted 06 Feb 2018 in reply to Patrick Link to this post

    I forgot to add the template .cshtml....

    01.@model Inspections.Inspections_DO
    02.<div class="k-edit-form-contaner" style="width:550px;">
    03.    <div class="editor-label"><label for="InspectionFinalFlag">Inspection Final Flag</label></div>
    04.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.InspectionFinalFlag))</div>
    05. 
    06.    <div class="editor-label"><label for="Date">Date</label></div>
    07.    <div class="editor-field">@(Html.Kendo().DatePickerFor(model => model.RequestDate))</div>
    08. 
    09.    <div class="editor-label"><label for="InspectionStatus">Inspection Status</label></div>
    10.    <div class="editor-field">@(Html.Kendo().DropDownListFor(model => model.InspectionStatus).BindTo(new List<SelectListItem>() { new SelectListItem() {Text ="- Select Item -", Value = "" }, new SelectListItem() { Text = "Pass", Value = "Pass" }, new SelectListItem() { Text = "Fail", Value = "Fail" } }))</div>
    11.     
    12.    <div class="editor-label"><label for="FinalPaymentRecommend">Recommendation for Final Payment</label></div>
    13.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.FinalPaymentRecommend))</div>
    14. 
    15.    <div class="editor-label"><label for="DEPCert">DEP Cert Language</label></div>
    16.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.DEPCert))</div>
    17. 
    18.    <div class="editor-label"><label for="Comments">Inspection Comments</label></div>
    19.    <div class="editor-field">@(Html.TextAreaFor(model => model.InspectionComments, new { @class="k-textbox", style = "width: 328px; height: 150px;" }))</div>
    20. 
    21.    <div class="editor-label"><label for="CloseoutStatus">Closeout Status</label></div>
    22.    <div class="editor-field">
    23.        @(Html.Kendo().DropDownListFor(model => model.CloseoutStatus)
    24.            .BindTo(new List<SelectListItem>() {
    25.                new SelectListItem() { Text = "- Select Item -", Value = "" },
    26.                new SelectListItem() { Text = "Pending", Value ="Pending" },
    27.                new SelectListItem() { Text = "Hold", Value = "Hold" },
    28.                new SelectListItem() { Text = "Completed", Value = "Completed" }
    29.                })
    30.            )
    31.    </div>
    32.    <div class="editor-label"><label for="DEPReport">DEP Report</label></div>
    33.    <div class="editor-field">
    34.        @(Html.Kendo().Upload().Name("uplDEPReport").ShowFileList(true))
    35.        @(Html.HiddenFor(model => model.InspectionReport))
    36.    </div>
    37.</div>
  3. Patrick
    Patrick avatar
    30 posts
    Member since:
    Jan 2018

    Posted 06 Feb 2018 in reply to Patrick Link to this post

    01.
    @model Inspections.Inspections_DO
    02.<div class="k-edit-form-contaner" style="width:550px;">
    03.    <div class="editor-label"><label for="InspectionFinalFlag">Inspection Final Flag</label></div>
    04.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.InspectionFinalFlag))</div>
    05. 
    06.    <div class="editor-label"><label for="Date">Date</label></div>
    07.    <div class="editor-field">@(Html.Kendo().DatePickerFor(model => model.RequestDate))</div>
    08. 
    09.    <div class="editor-label"><label for="InspectionStatus">Inspection Status</label></div>
    10.    <div class="editor-field">@(Html.Kendo().DropDownListFor(model => model.InspectionStatus).BindTo(new List<SelectListItem>() { new SelectListItem() {Text ="- Select Item -", Value = "" }, new SelectListItem() { Text = "Pass", Value = "Pass" }, new SelectListItem() { Text = "Fail", Value = "Fail" } }))</div>
    11.     
    12.    <div class="editor-label"><label for="FinalPaymentRecommend">Recommendation for Final Payment</label></div>
    13.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.FinalPaymentRecommend))</div>
    14. 
    15.    <div class="editor-label"><label for="DEPCert">DEP Cert Language</label></div>
    16.    <div class="editor-field">@(Html.Kendo().CheckBoxFor(model => model.DEPCert))</div>
    17. 
    18.    <div class="editor-label"><label for="Comments">Inspection Comments</label></div>
    19.    <div class="editor-field">@(Html.TextAreaFor(model => model.InspectionComments, new { @class="k-textbox", style = "width: 328px; height: 150px;" }))</div>
    20. 
    21.    <div class="editor-label"><label for="CloseoutStatus">Closeout Status</label></div>
    22.    <div class="editor-field">
    23.        @(Html.Kendo().DropDownListFor(model => model.CloseoutStatus)
    24.            .BindTo(new List<SelectListItem>() {
    25.                new SelectListItem() { Text = "- Select Item -", Value = "" },
    26.                new SelectListItem() { Text = "Pending", Value ="Pending" },
    27.                new SelectListItem() { Text = "Hold", Value = "Hold" },
    28.                new SelectListItem() { Text = "Completed", Value = "Completed" }
    29.                })
    30.            )
    31.    </div>
    32.    <div class="editor-label"><label for="DEPReport">DEP Report</label></div>
    33.    <div class="editor-field">
    34.        @(Html.Kendo().Upload().Name("uplDEPReport").ShowFileList(true))
    35.        @(Html.HiddenFor(model => model.InspectionReport))
    36.    </div>
    37.</div>
  4. Patrick
    Patrick avatar
    30 posts
    Member since:
    Jan 2018

    Posted 07 Feb 2018 Link to this post

    Nevermind.... I was able to resolve the issue myself.... i failed to realize during a change in structure that I was failing to actually bring back the ids of the items in the first place.... once i added the id field to the list the model did what I expected it to do.
  5. Stefan
    Admin
    Stefan avatar
    2893 posts

    Posted 08 Feb 2018 Link to this post

    Hello, Patrick,

    I'm glad to hear that the issue is resolved.

    Please have in mind that the field marked as ID is very important for all of the CRUD operations. If the field is not returned after an update or create the Grid will keep making requests for it in order to retrieve it.

    I can suggest checking the CRUD article in the documentation as it can prove helpful:

    https://docs.telerik.com/kendo-ui/framework/datasource/crud

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top