I have this code
<SfGrid @ref="Grid" DataSource="Orders" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<GridEvents Created="Created" DataBound="DataBound" OnActionComplete="OnActionComplete" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"
NewRowPosition="NewRowPosition.Bottom">
</GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.id) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.Name) HeaderText="Customer Name" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.country) HeaderText="Ship Country" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public SfGrid Grid { get; set; }
public List
{
public int id { get; set; }
public string Name { get; set; }
public string country { get; set; }
}
public int CurrentViewRecordCount { get; set; }
public async void Created()
{
await Grid.EditCell(0, nameof(Order.id));
}
public async void DataBound()
{
CurrentViewRecordCount = (await Grid.GetCurrentViewRecords()).Count;
}
void OnActionComplete(ActionEventArgs<Order> args)
{
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))
{
this.Grid.AddRecordAsync();
}
}
Hi Haneen,
Greetings from Syncfusion support.
Query: “when i add a new record automatically it save just one recor”
We have prepared a sample using your code example and found that on saving the new records, an empty record gets inserted into the newly added record with a value. But before proceeding further with your requirement, we need some more details about the issue you are facing. So kindly share the following details to validate the reported query further at our end.
The above details will be very helpful in understanding your requirement and providing a solution as early as possible.
Regards,
Vignesh Natarajan
Hi , thank you for your reply
Hi Haneen,
Thanks for the update.
We have analyzed your query and we suspect that the reported issue occurs because the AddRecord method triggers before the previously added record is saved. So we introduced the time delay before calling AddRecord method. Also we have declared the Orders as new List<Order>(). Kindly check the attached sample for your reference. If you face any difficulties then kindly get back to us.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp1-1302435764.zip
Also we would like to inform that we have faced issues when rendering the Row Position as bottom in Grid EditSettings. So we have considered this as an bug and we will fix this issue internally and it will be included on our Volume 2, 2022 release which is expected to be rolled out on or before end of June. We will update you once the release is rolled out.
Until then we appreciate your patience.
Regards,
Monisha
Thank you very much it works fine
Haneen,
Most welcome. We are glad that it works.
Hi Haneen,
We are glad to announce that our Essential Studio 2022 Volume 2 release v20.2.0.36 is rolled out and we have included fix for the issue “Issue with Adding Records when using Row Position as Bottom ” in our release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Monisha