- Home
- Forum
- ASP.NET MVC - EJ 2
- Null value while editing inline a grid using the CrudUrl.
Null value while editing inline a grid using the CrudUrl.
Hi,
I am trying to edit inline a grid using the CrudUrl. I use your Grid/UrlAdaptor example that I have modified like this:
[View]
@Html.EJS().Grid("gridName").DataSource(ds => ds.Url(@Url.Action("UrlDatasource", "Grid")).CrudUrl("/Grid/SetCrud").Adaptor("UrlAdaptor")).AllowSorting().Columns(col =>
{
col.Field("OrderID").IsPrimaryKey(true).HeaderText("Order ID").Width("120").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("170").Add();
col.Field("Freight").HeaderText("Freight").Width("130").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("C2").Add();
col.Field("ShipCity").HeaderText("Ship City").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
}).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete" }).Render()
[Controller]
public ActionResult SetCrud([FromBody]CRUDModel<Orders> value, string action)
{
var ord = value.value;
...
}
When I delete a line, the value.Key in the controller is good. But when I update a line I only get null value.
SIGN IN To post a reply.
9 Replies
VS
Vignesh Sivagnanam
Syncfusion Team
December 11, 2020 03:27 PM UTC
Hi Laurent
Greetings from Syncfusion support
Based on your query we found that you have received null value when update the editing value in the grid. So we have prepared a sample based on your query with the CrudUrl with editing but we did not face the mentioned issue at our end.
For your convenience we have attached the sample and please find the sample for your reference
Sample : https://www.syncfusion.com/downloads/support/forum/160510/ze/passfunc674039759-2010845971.zip
Screenshot for your reference,
If you are still facing the issue, kindly share the following details that will be helpful for us to provide better solution.
- Share your complete Grid rendering code.
- Share your complete Controller Page code.
- If possible please replicate the issue in the attached sample.
- Syncfusion package version
Regards
Vignesh Sivagnanam
LA
Laurent
December 11, 2020 06:02 PM UTC
Thanks for your reply. Your sample works for me. But my project is not in Asp.Net Core but in .Net Framework 4.8.
Attachment: AspNetGrid_a19b5094.zip
I have attached a sample in the good target that reproduce the issue.
Attachment: AspNetGrid_a19b5094.zip
VS
Vignesh Sivagnanam
Syncfusion Team
December 17, 2020 01:27 PM UTC
Hi Laurent
Sorry for the late reply
We checked the attached sample and we can able to reproduce the mentioned issue at our end. When we validate the mentioned issue and we suspect that Model reference have been conflicted due to instance and property variable same.
To resolve the issue we suggest to replace the name from value to myvalue. Please refer the below Code example and screenshot for your reference,
Code Example:
|
public ActionResult CrudUpdate(CRUDModel<OrdersDetails> myvalue)
{
var ordd = myvalue;
…..
} |
Screenshot :
Please refer the below Documentation for your reference:
Regards
Vignesh Sivagnanam
LA
Laurent
December 23, 2020 12:43 PM UTC
Thanks, it works for me now.
VS
Vignesh Sivagnanam
Syncfusion Team
December 24, 2020 02:22 PM UTC
Hi Laurent
We are happy to hear that your issue has been resolved.
Please get back to us if you need further assistance.
Regards,
Vignesh Sivagnanam
LA
Laurent
January 3, 2021 09:57 AM UTC
Hi,
I finally migrated my project to Asp.Net Core, .Net 5 and now my grid doesn't display the items of the grid.
I tried to migrate the sample you gave me but I can't figure it out.
Can you send me the same example in .Net 5 ?
Best regards,
Laurent
VS
Vignesh Sivagnanam
Syncfusion Team
January 4, 2021 11:03 AM UTC
Hi Laurent
Thanks for the update
Based on your query we understand that you have faced difficulties while preparing the sample in the Framework .Net 5. We have prepared a sample based on your query Grid with CRUD Url.
Please refer the below Code Example and sample for your reference
|
<ejs-grid id="Grid" allowPaging="true" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete" })">
<e-data-manager url="/Home/UrlDatasource" crudUrl="/Home/CrudUpdate" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings>
<e-grid-columns>
………………….
</e-grid-columns>
</ejs-grid> |
By default the JSON results are returned in camelCase format and the grid field names are also changed in camelCase. To resolve the issue Please add the below code in the startup.cs file.
|
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver =
new DefaultContractResolver();
});
} |
Please refer the below Documentation for your reference,
Documentation : https://ej2.syncfusion.com/aspnetcore/documentation/grid/data-binding/#troubleshoot-grid-render-rows-without-data
Regards
Vignesh Sivagnanam
LA
Laurent
January 4, 2021 12:12 PM UTC
Thanks a lot! It works fine.
Have a nice day,
Laurent
VS
Vignesh Sivagnanam
Syncfusion Team
January 5, 2021 10:00 AM UTC
Hi Laurent
We are happy to hear that the provided solution works fine at your end.
Please get back to us if you need any further assistance.
Regards,
Vignesh Sivagnanam
SIGN IN To post a reply.
- 9 Replies
- 2 Participants
-
LA Laurent
- Dec 10, 2020 03:52 PM UTC
- Jan 5, 2021 10:00 AM UTC