when i add a new record automatically it save just one record

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 Orders { get; set; } 

 public class Order

    {

        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();

        }

    }

 }

 the code implement correctly just once then it doesnt save


6 Replies

VN Vignesh Natarajan Syncfusion Team June 22, 2022 06:09 AM UTC

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.


  1. Do you want to insert a new form automatically after inserting a record?
  2. EditCell method of Grid is used to edit the cell when Grid is in batch mode. But in your sample, you have defined the edit mode as Normal editing. So kindly confirm the edit mode you want to use.
  3. Share more details about your requirement
  4. Also,      share your Syncfusion Blazor NuGet package version details.


The above details will be very helpful in understanding your requirement and providing a solution as early as possible.


Regards,

Vignesh Natarajan



HA Haneen Alfakhry replied to Vignesh Natarajan June 24, 2022 07:23 PM UTC

Hi , thank you for your reply 

  1. Do you want to insert a new form automatically after inserting a record? yes , I want  to insert a new form automatically after inserting a record
  2. EditCell method of Grid is used to edit the cell when Grid is in batch mode. But in your sample, you have defined the edit mode as Normal editing. So kindly confirm the edit mode you want to use.            I dont want to use the batch mode , i want a normal mode
  3. Share more details about your requirement      (All I need is after saving a record a new empty record is automatically added to fill in )  
  4. Also,      share your Syncfusion Blazor NuGet package version details.(19.4.0.54)




MS Monisha Saravanan Syncfusion Team June 27, 2022 01:26 PM UTC

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





HA Haneen Alfakhry June 28, 2022 07:30 AM UTC

Thank you very much it works fine


Haneen,



SS Swetha Srikumar Syncfusion Team June 28, 2022 01:00 PM UTC

Most welcome. We are glad that it works.




MS Monisha Saravanan Syncfusion Team July 5, 2022 05:26 AM UTC

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.


https://www.syncfusion.com/forums/175975/essential-studio-2022-volume-2-main-release-v20-2-0-36-is-available-for-download


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


Loader.
Up arrow icon