This is a migrated thread and some comments may be shown as answers.

Grid .update not posting back to controller

5 Answers 860 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 20 Jan 2019, 02:39 AM

I changed data in the Processing Order column (and it shows the red triangle in upper left corner of the cell) and clicked the 'Save Changes' button but the controller doesn't get hit.  I've checked the controller name and method to make sure it matches.  Everything seems right.  I tried copying the .update statement from another working page in the same controller and it doesn't reach the controller/action method either.

The F12 console doesn't show errors.

VIEW

=======================================

@(Html.Kendo().Grid<Verdant.ViewModels.Manage.View_Remit_Config_Contract_PayeeVM>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.EntityName).Width(70);
            columns.Bound(o => o.ProcessingOrder).Width(30);
            columns.Command(command => command.Destroy()).Width(15);
        })
        .ToolBar(toolbar =>
        {
            toolbar.Save();
            toolbar.Custom().Text("Add Payee").Action("RemitConfigurationPayeeAdd", "Manage", new { remitItemID = @Html.Raw(Model.RemitItemID) });
        })
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .Model(model =>
        {
            model.Id(e => e.RemitItemID);
            model.Field(e => e.RemitItemID).Editable(false);
            model.Field(e => e.EntityName).Editable(false);
            model.Field(e => e.ProcessingOrder).Editable(true);
        })
        .Read(read => read.Action("RemitConfigurationContract_Payee", "Manage", new { remitItemID = @Html.Raw(Model.RemitItemID) }))
        .Update(update => update.Action("RemitConfigurationPayee_Update", "Manage"))
        .Destroy(destroy => destroy.Action("RemitConfigurationPayee_Delete", "Manage"))
        .PageSize(20)
        .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
        )
)

CONTROLLER

===============

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult RemitConfigurationPayee_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<View_Remit_Config_Contract_PayeeVM> payees)
        {
            if (payees != null && ModelState.IsValid)
            {
                foreach (var p in payees)
                {
                    ManageFunctions.RemitConfigurationPayee_Update(p);
                }
            }

            return Json(payees.ToDataSourceResult(request, ModelState));
        }

 

5 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 23 Jan 2019, 06:59 AM
Hi John,

I have investigated the provided Kendo UI Grid definition and it seems that everything is declared correctly. Can ensure that correct URL gets hit? This can be observed in the Network tab of the DevTools developer tools of the browser. When the "Save Changes" button is clicked, a request is sent to the server and within the Preview tab of the request, the URL can be examined.

Furthermore, I have created a sample project following the provided code snippets. Can you modify it in order to replicate the issue you are facing on your side? This will give me the opportunity to obtain the big picture of the project and provide accurate and clear-cut suggestions.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
John
Top achievements
Rank 1
answered on 23 Jan 2019, 03:00 PM

Hi Tsvetomir,

It is not getting to the controller but the Network shows it is trying to hit the wrong Page.  Internet Explorer F12 shows errors.  Picture attached.

Thoughts?

Thanks, John

0
Tsvetomir
Telerik team
answered on 24 Jan 2019, 03:06 PM
Hi John,

The exception that is thrown is because a CORS HTTP request is initiated but it is not allowed. Initially, the Cross-Origin Resource Sharing is a mechanism that uses additional HTTP headers to tell the browser if the application should be allowed to access resources from a server which is at a different origin. 

A web application makes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, and port) than its own origin. More information can be found in the following MDN article:

Cross-Origin Resource Sharing (CORS)

The response header that is responsible for allowing such requests is Access-Control-Allow-Origin. It indicates whether the response can be shared with requesting code from the given origin. 

Access-Control-Allow-Origin

Also, there is an article on StackOverflow which covers how to disable the same origin policy for Internet Explorer:

Disable same origin policy Internet Explorer

Please take a look at the articles above and let me know if there is something that needs additional clarification.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
John
Top achievements
Rank 1
answered on 24 Jan 2019, 03:47 PM
Thanks but I don't think I'm trying to do anything cross origin.  Is this something the Kendo grid is doing behind the scenes?  I'm using the same .update pattern as in other working pages.  Why would this page be different?  It is trying to hit the same controller that displayed the view, just a different action method.  How is this a cross origin request?  Everything runs on one server, same port.
0
Tsvetomir
Telerik team
answered on 28 Jan 2019, 11:07 AM
Hi John,

Based on the provided information, I cannot give a firm conclusion where does the issue stem from. In order for me to provide an accurate suggestion, I will need to investigate the faulty behavior locally. Can you send me a project in which the problem can be replicated? You can use the project I have sent previously as a base. All that has to be done in order to get the project to work is to add the Kendo.Mvc.dll in the bin folder of the project.

Also, can you confirm that the used framework is ASP.NET MVC and not ASP.NET Core? There is a difference between the two when handling the authentication functionality. 

Looking forward to your reply.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
John
Top achievements
Rank 1
Share this question
or