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

Leaving Grid in EDIT MODE when Using Custom errors and ModelState

3 Answers 341 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Buddy
Top achievements
Rank 2
Buddy asked on 20 Apr 2015, 07:03 PM
I followed the example for Ajax custom errors and server side modelstate errors, however, the grid (inline editing) goes out of Edit Mode after  my javascript error event is called.

We would like to leave the grid in error mode.

Not using .cancelChanges();

// javascript 

function grid_error(e) {
    var grid = $("#CPRProductLineGrid").data("kendoGrid");
    var knotify = $("#popupNotification").data("kendoNotification");

    if (e.errors) {
        var message = "";

        $.each(e.errors, function(key, value) {
            if ('errors' in value) {
                $.each(value.errors, function() {
                    message += this + "<br />";
                });
            }
        });

        knotify.show({
            title: "Validation Error",
            message: message
        }, "error");
  
       
       //grid.cancelChanges();

    }
}

// controller

           foreach (var item in  validator.GetValidationErrors())
                {
                    ModelState.AddModelError("GroupCode1", item);
                }

           return Json(ModelState.ToDataSourceResult());

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 22 Apr 2015, 01:40 PM
Hi Buddy,

In order to prevent the Grid from closing the edit form, you should handle the dataBinding event and prevent it.

function grid_error(e) {
    var grid = $("#CPRProductLineGrid").data("kendoGrid");
    var knotify = $("#popupNotification").data("kendoNotification");
 
    if (e.errors) {
      /*...*/      
      grid.one("dataBinding", function(args) {
          args.preventDefault();
      });
 
    }
}


Regards,
Rosen
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Buddy
Top achievements
Rank 2
answered on 22 Apr 2015, 01:52 PM
This does not work in 2014.3.1411 the args are ignored, the sync is fired and the edit mode always closes.
0
Rosen
Telerik team
answered on 23 Apr 2015, 08:21 AM
Hi Buddy,

There should be no difference in the version used. Here you can find a test page which demonstrates the discussed approach. Also I have created a short video which captures the test page behavior. Please take a look maybe I'm missing something obvious.

Regards,
Rosen
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Buddy
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Buddy
Top achievements
Rank 2
Share this question
or