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. Image for the cookie policy date

Problem with record ID in "endadd" client-side method

I have a grid where I'm trying to use the endadd method to redirect to a detail page after a record is added. I'm pretty sure it worked when I first implemented it a month or two ago. However, it doesn't work anymore. My event is:

function endadd(args)
    {
      window.location = "/OrderItemsEdit?o=" + args.data.OrderID;
    }

the related field/column is:

  col.Field("OrderID").HeaderText("ID").IsPrimaryKey(true).IsIdentity(true).Visible(false).Add();

From what I can tell from reading the documentation, the IsIdentity(true) should result in an auto-incremented value. However, args.data.OrderID is zero, and results in an error in the target controller due to an invalid ID.

Should this work the way I'm understanding? If not, is there a way to achieve what I want? I was hoping that there was an event that would happen after the CRUD insert operation came back from the server, so it could get the actual ID that was auto-generated in the database, but I didn't see an event for that.

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team January 20, 2017 10:17 AM UTC

Hi Brian, 

Thanks for contacting Syncfusion support. 

As from your query,If we enable the Isidentity property for Auto increment column then we must handle Auto increment column. Example if we bound the remote data source for the Grid, then we will to return the Isdentity column while adding the record. 
So, we are the responsibility to handle the Isidentity property. While performing CRUD operation in Grid with IsIdentity column, we need to return the modified value, because of we have handled IsPrimary key column value in server side. So, we suggest you to return the modified value while performing the CRUD operation in Grid like as follows, 
Code example
public ActionResult Insert(OrdersView value) 
        { 
            value.OrderID = ++count; //Auto increment the value for isIdnetity property 
            order.Add(value); 
            return Json(value, JsonRequestBehavior.AllowGet); 
        } 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Live Chat Icon For mobile
Up arrow icon