We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Javascript ejGrid undo row delete if server returns error

Thread ID:





125713 Sep 5,2016 09:20 PM UTC Sep 6,2016 07:15 AM UTC JavaScript 1
Tags: ejGrid
Ray Cacciatore
Asked On September 5, 2016 09:20 PM UTC

I'm using ejGrid with the toolbarSettings that include the "delete" option. When a row is deleted, it calls a Web Api delete action in my controller. Sometimes, an error can occur and the server cannot delete the record for some reason. My jQuery function executed the error code and I display the error message on the page. However, the ejGrid still removes the record on the client side. The row disappears in the ejGrid.
How do I undo this row removal in the ejGrid when an error comes back from the server?

Prasanna Kumar Viswanathan [Syncfusion]
Replied On September 6, 2016 07:15 AM UTC

Hi Ray, 

Thanks for contacting Syncfusion support. 

We created a sample in web API adapter with a delete action in the controller. In the controller we throw an exception in delete action before the server delete the record. When we delete the record in the sample it throws an exception and grid does not remove the record from the client side. 

In our sample we display the error message using actionFailure event of ejGrid. We can handle any exceptions(server-side) in the actionFailure event. In this event we can get error messages in arguments and display the error messages in the alert window. 

Find the code example and sample: 

<script type="text/javascript"> 
    $(function () { 
                        dataSource: ej.DataManager({ url: "/api/Orders", adaptor: "WebApiAdaptor" }), 
            allowPaging: true, 
           editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
            pageSettings: { pageSize: 4 }, 
            actionFailure : "Failure", 
            toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Delete] }, 
            columns: [ 
function Failure(args) { 
   public void Delete(int id) 
            throw new Exception(); 
            var order = db.EmployeePhotoes.Find(id); 

Refer to the Help document for the actionFailure event. 

For your convenience we attached a video demonstration. 

To reproduce the issue we need the following details, 

1. Code example of a Grid and controller. 

2. Essential Studio Version details. 

3. If possible, replicate the issue in the attached sample. 

Prasanna Kumar N.S.V 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon