Edit & save

Mode 1:
I save the data to database in ActionBegin funciton,  then I refresh the datasource, so the new data have two records in the datasource. I cant delete and edit the new data for tracker errors. 

Mode 2: I saved the data to database in the ActionCompleted Handle, the new added data has no Id. 

Only refreshed the page, not a spa.
A client ADD a record in one page. then the others who opened the same page would get the new record in the same time. so I must get the newest record in the database.

I want to know when did the grid componet  add the new data to the datasource?
Would you give some advice CRUD about the data grid?

public async void ActionBeginHandler(ActionEventArgs<Country> args)
{
// Here you can customize your code
actionInfo += "ActionBeginHandler, ";
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
{
if (args.Action == "edit")
{
await countryService.UpdateAsync(args.Data);
}
if (args.Action == "add")
{
// await countryService.SaveDataToDatabase();
AmISender = true;
await countryService.AddAsync(args.Data);
}
}
else if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)
{
await countryService.RemoveAsync(args.Data);
}
else if (args.RequestType == Syncfusion.Blazor.Grids.Action.Add)
{
}
}

1 Reply 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 22, 2020 09:31 AM UTC

Hi Chenyapeng,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I cant delete and edit the new data for tracker errors and I saved the data to database in the ActionCompleted Handle, the new added data has no Id 
 
From your query we understand that you are facing issue while performing CRUD action in Grid. We have analyzed your query and we suspect that you might not have enabled IsPrimaryKey property in Grid Column. If yes, kindly ensure to define the PrimaryKey property to any of the available GridColumn whose value is unique. Based on the PrimaryKey column value only CRUD in Grid will take place.  
 
Refer our UG documentation for your reference 
 
 
After ensuring the above solution, if you are still facing the issue. kindly get back to us with following details.  
 
  1. Share your Grid code example.
  2. Are you facing any exception in browser console while perform CRUD action in Grid. If yes, share the screenshot of the issue.
  3. Share the details about your datasource along with your model class properties.
  4. If possible share the issue reproducible sample.
 
Above requested details will be helpful for us to validate the reported issue at our end and provide  solution as soon as possible.  
 
Regards, 
Vignesh Natarajan 
 
 


Marked as answer
Loader.
Up arrow icon