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

How to prevent grid from retrying update on error

2 Answers 303 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Quentin
Top achievements
Rank 1
Quentin asked on 03 Jun 2013, 04:16 PM
Hi all,

I have been browsing the forums and stack overflow and can't find a solution to this.

I implemented the generic Kendo "error" js method as shown in the demos in order to show errors on updates, and then I added the error to my modelstate.

When the grid tries to update and an error is thrown - it automatically retries up to 4 time. Is there a way to prevent this retry from happening?

I am using MVC4 - and a standard MVC controller.

Here is my controller error handler:

catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);               
                return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
            }


Here is the js code for showing the error:

function error(e) {
    if (e.errors) {
        var message = "Errors:\n";
        $.each(e.errors, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function () {
                    message += this + "\n";
                });
            }
        });
 
        alert(message);
    }
}


The grid uses a standard Async update method in order to perform the update, and this goes to an MVC controller and not an API controller.

My question again: When the grid tries to update and an error is thrown - it automatically retries up to 4 time. Is there a way to prevent this retry from happening?

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 05 Jun 2013, 09:32 AM
Hi Quentin,

I tried to reproduce the problem locally but to no avail – everything is working as expected on our side (no additional requests are made after the first request returns error). Could you please provide runable project where the issue is reproduced and more information about the exact steps to reproduce it on our side? This would help us pinpoint the exact reason for this behavior.

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Quentin
Top achievements
Rank 1
answered on 05 Jun 2013, 12:23 PM
Hi Vladimir,

When you mentioned that you couldn't recreate it I decided to look at the code more carefully.

I had some additional events that were being fired on certain actions so I removed them and tried again.

The problem was that I had a refresh method running as below. I removed it and the retry stopped occurring.
function gridRequestEnd(e) {
    if (e.type == "destroy" || e.type == "update") {
        //execute your custom code
        $("#CreativesGrid").data("kendoGrid").dataSource.read();
        $("#CreativesGrid").data("kendoGrid").refresh();
        $("#CreativesGrid").data("kendoGrid").dataSource.sync();
Thanks for the help,
Quentin
Tags
Grid
Asked by
Quentin
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Quentin
Top achievements
Rank 1
Share this question
or