We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Manually update row when clicked on Save button in edit dialog

Hi,

i made generic grid which inherit from SfGrid and made custom edit dialog which is generated. Because it is generated a dont bind inside components directly to grid entity but to my custom entities. Problem i have is that when i click on save button, changes that were made in my custom edit dialog are not saving to the row entity and are not send to the API in PUT request(old entity is send). Im using remote data binding with ODataV4Adaptor. Is it possible to manully update the edited entity or give the grid entity to be send in PUT request?


6 Replies 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team January 13, 2023 02:38 PM UTC


Hi Ladislav,


We suspect that you are expecting to update the record in Grid bus using an button click from customized dialog. If so we suggest you to use UpdateCellAsync/ SetRowData methods to update the Grid row. It will update the record as per the passed value in arguments.


If we misunderstood your query or if you have further queries then kindly share the below details to proceed further at our end.


  1. Share us the entire code snippet.
  2. Share us the video demonstration of the issue.
  3. If possible kindly share us a simple issue reproduceable sample.


Above requested details will be very helpful in validating the reported query at our end and provide solution as early as possible.


Regards,

Monisha


Marked as answer

LP Ladislav Polacek January 16, 2023 02:35 PM UTC

Thanks, that was what i needed. I have two more problems, im doing SetRowDataAsync in OnActionBegin event for Action.Save. But the same event is called when button Save is clicked from Add or Edit dialog, is it possible to distinguish the dialog type(Add/Edit) from something? Second problem is same as my original question but for Add, when SetRowDataAsync is called, inside the method PUT request is sent. For adding i only found AddRecordAsync, but inside this method no POST request is sent. Do i need to call another method? In both scenarios Add/Edit im setting property Cancel = true on OnActionBegin event argument because i dont want the original Save logic to run.



MS Monisha Saravanan Syncfusion Team January 17, 2023 01:30 PM UTC


Hi Ladislav,


Query: “is it possible to distinguish the dialog type(Add/Edit) from something? ”


Yes, we can use Action from the argument to differentiate between Add and Edit operations. Kindly check the below attached code snippet for your reference.


public void ActionBeginHandler(ActionEventArgs<Order> args)

    {

        if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))

        {

            if (args.Action == "Add")

            {

                // it triggers when we click save button after performig Add

            }

            else if(args.Action == "Edit")

            {

                // it triggers when we click save button after performing Edit

            }

        }

 

    }


 For adding i only found AddRecordAsync -> For adding we have only AddRecordAsync method, for updating we can use UpdateRowAsync method


Regards,

Monisha



LP Ladislav Polacek January 18, 2023 07:17 AM UTC

Thanks for response. Problem with manually adding new record with AddRecordAsync is that it will not call POST request to server. When UpdateRowAsync is used it will call PUT/PATCH request to server and after that i can call sfGrid.Refresh() and it looks same as the default Save logic. But AddRecordAsync just adds new record to the grid and nothing else is happening, i cant call SetRowDataAsync on the new record because it doesnt have generated Id from server.



LP Ladislav Polacek January 18, 2023 08:03 AM UTC

I resolved the issue with adding by not calling AddRecordAsync but in OnActionBegin i just assign my new entity to args.Data and dont skip the event and it works.



MS Monisha Saravanan Syncfusion Team January 19, 2023 05:47 AM UTC

Hi LadiSlav,


We are glad to hear that the reported issue resolved on your own. Kindly get back to us if you need further assistance. As always we will be happy to help you.


Regards,

Monisha


Loader.
Live Chat Icon For mobile
Up arrow icon