problem with insert

after inserting record the grid fails


this happens



Attachment: TestSyncfucion_a478e327.rar

3 Replies 1 reply marked as answer

SK Sujith Kumar Rajkumar Syncfusion Team December 21, 2020 12:31 PM UTC

Hi Erik, 
 
Greetings from Syncfusion support. 
 
We checked the reported problem in the attached sample and would like to let you know that it was occurring due to the serialization problem in the ASP.NET Core where it returns the JSON results in camelCase format by default, because of which your newly added data source field names were returned in camelCase as ‘code’ and ‘description’ whereas the columns fields are set as ‘Code’ and ‘Description’. The column field names are case-sensitive and since the names do not match, the added value was not getting displayed in the Grid. 
 
You can resolve this problem by serializing and returning them in the PascelCase format using the below approach, 
 
If the ASP.NET CORE version is 2.X then add the below code in startup.cs file 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddMvc().AddJsonOptions(options => 
    { 
        options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); 
    }); 
} 
 
 
If the ASP.NET CORE version is 3.X then add the below code in startup.cs file 
 
public void ConfigureServices(IServiceCollection services) 
{ 
    services.AddMvc().AddNewtonsoftJson(options => 
    { 
        options.SerializerSettings.ContractResolver = new DefaultContractResolver();
    });
 
} 
 
 
Please check the below documentation link for more details on this, 
 
 
Also, the Grid Editing feature requires a primary key column for performing the CRUD operations. To define the primary key, set isPrimaryKey property of e-grid-column tag helper as true in particular column. More details on this can be checked in the below documentation link, 
 
 
We have modified the shared sample based on this for your reference. You can find it below, 
 
 
Note: Since you had used your own db connection for fetching data, we had set local data in the above Grid sample. 
 
Please get back to us if you require any further assistance. 
 
Regards, 
Sujith R 



ER Erik December 24, 2020 09:57 PM UTC

Greetings Sujith Kumar Rajkumar, and solved the problem with these lines is StarUp class.


services.AddMvc().AddJsonOptions(o =>
{
o.JsonSerializerOptions.PropertyNamingPolicy = null;
o.JsonSerializerOptions.DictionaryKeyPolicy = null;
});

that I found in an example, thank you very much for your help.



Marked as answer

SK Sujith Kumar Rajkumar Syncfusion Team December 28, 2020 05:47 AM UTC

Hi Erik, 
 
You’re welcome. We are glad to hear that your problem has been resolved. 
 
Please get back to us if you require any further assistance. 
 
Regards, 
Sujith R 


Loader.
Up arrow icon