- Home
- Forum
- ASP.NET MVC - EJ 2
- ASP.NET MVC Grid - columns not updated after Edit->Put / ODATA / EF
ASP.NET MVC Grid - columns not updated after Edit->Put / ODATA / EF
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
{
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");
})....
SIGN IN To post a reply.
3 Replies
HJ
Hariharan J V
Syncfusion Team
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,
- Share the full Grid code.
- Share the screenshot of the post from the network tab.
Please get back to us if you need further assistance.
Regards,
Hariharan
AN
Andreas
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
HJ
Hariharan J V
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
AN Andreas
- May 21, 2019 08:43 PM UTC
- May 23, 2019 10:48 AM UTC