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

Deleted row removed from grid even though errors returned in Destroy method

1 Answer 592 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 2
Shawn asked on 30 Jun 2012, 01:29 PM
I'm using Ajax binding, with the Destroy command.  The controller method fails with a business exception, which I add to the ModelState with the AddMModelError method.  This is then returned at the end of the method with the ModelState.ToDateSourceResult().
In the UI I have the error event of the grid hooked up, which correctly displays the error as expected.  However, the "deleted" row is still removed from the Grid.  Am I doing something wrong?

1 Answer, 1 is accepted

Sort by
0
Accepted
Burke
Top achievements
Rank 1
answered on 28 Jul 2012, 09:44 PM
Shawn

I think that you need to tell the grid to rollback the changes.  Set the events property on the grid to get the error (which it sounds like you are already doing)

.
Events(events => events.Error("error"));

Now select the grid in the error function and rollback the changes.  I'm assuming your grid is named "grid".

var error = function() {
var grid = $("#grid").data("kendoGrid");
// cancel changes
grid.cancelChanges();
}

That should do it.
Tags
Grid
Asked by
Shawn
Top achievements
Rank 2
Answers by
Burke
Top achievements
Rank 1
Share this question
or