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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

128417 Jan 19,2017 08:01 PM Jan 20,2017 05:17 AM ASP.NET MVC 1
loading
Tags: Grid
R Brian Lindahl
Asked On January 19, 2017 08:01 PM

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.

Venkatesh Ayothi Raman [Syncfusion]
Replied On January 20, 2017 05:17 AM

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. 


CONFIRMATION

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.

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

;