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

ASP.NET MVC Grid - columns not updated after Edit->Put / ODATA / EF

Thread ID:

Created:

Updated:

Platform:

Replies:

144771 May 21,2019 08:43 PM UTC May 23,2019 10:48 AM UTC ASP.NET MVC - EJ 2 3
loading
Tags: Grid
Andreas
Asked On May 22, 2019 05:58 AM UTC

Hi, I am trying to get it to work with the controller generated by visual studio for ODATA V3 and EF. The grid initially renders well and shows all data.

This is the code for Put. After a successful Put my record gets updated and code 204 is returned as far as I know. But no data is returned and the grid is not updated to the change. How can I get the grid updated after the put? A page reload shows the correct grid.

Controller:

       // PUT: odata/TodoItems(5)

        public IHttpActionResult Put([FromODataUri] string key, Delta patch)

        {

            Validate(patch.GetEntity());

            TodoItem todoItem = db.TodoItems.Find(key);

            if (todoItem == null)

            {

                return NotFound();

            }

            patch.TrySetPropertyValue("CreatedAt", todoItem.CreatedAt);

            patch.Put(todoItem);

                db.SaveChanges();

 

            return Updated(todoItem);

        }


Grid:

   @Html.EJS().Grid("OData").DataSource(dataManger =>

 {

     dataManger.Url("/odata/TodoItems").CrossDomain(true).Adaptor("ODataAdaptor");

 })....


Hariharan J V [Syncfusion]
Replied On May 22, 2019 04:07 PM UTC

Hi Andreas, 
  
Thanks for contacting Syncfusion support. 
  
We have analyzed your query and the codes which you have shared with us. We suspect that the problem is with the way you are returning the result from the server side “Put” method. We suggest you to return the result from the server side method as a Json. Please refer the code example below, 
  
        // PUT: odata/Products(5) 
        public IHttpActionResult Put([FromODataUri] int key, Delta<Product> patch) 
        { 
            .  .  . 
            return Json(product);     //Return as Json 
        } 
  
  
And also we suggest you to ensure whether you have provided “isPrimaryKey” for a column in Grid, as based on the primary key column only, the CRUD actions will take place. 
Documentation : 
  
If you are still facing the problem, please get back to us with the following details, 
  1. Share the full Grid code.
  2. Share the screenshot of the post from the network tab.
  
Please get back to us if you need further assistance. 
  
Regards, 
Hariharan 


Andreas
Replied On May 22, 2019 07:08 PM UTC

Hariharan,

Thanks a lot! Your proposed solution works like charme. Wouldnt it be good to mention this in the documentation. Its really hard to figure out.

return Json(product);     //Return as Json 

Thanks you so much,
Andreas

Hariharan J V [Syncfusion]
Replied On May 23, 2019 10:48 AM UTC

Hi Andreas, 
  
Thanks for your update. 
  
We are happy to hear that your issue has been resolved. And we have logged this scenario in our documentation task and which will available in any of our upcoming releases. 
  
Regards, 
Hariharan 


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.

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

Live Chat Icon For mobile
Live Chat Icon