Prevent moving forward without user confirmation during Syncfusion Grid Edit

I'm trying to use a "Save" button to handle grid edits.

I want the user to confirm with "Ok" before proceeding with the save.

Currently the code execution moves forward even without the user clicking either "Ok" or "Cancel".

Image_4467_1753794966771


Image_6627_1753794966771


Image_2917_1753794966771

How to make sure the Save operation proceeds only when the user clicks "Ok"?

    private async Task SaveAllAsync()
    {
        // Show the confirmation dialog
        // The control should not proceed until the user has clicked "Ok". But it does, which is not the behavior I want.
        await Grid.EndEditAsync();

        // Get the changes and the unchanged data
        var gridData = Grid.DataSource;
        if (gridData is null) return;

        // Save gridData. Emulate API call that lasts 4 seconds
        await Task.Delay(4000);

        // Show success confirmation
        ShowSuccess("All model data Saved Successfully.");
    }


This is the runnable sample for your reference:

https://blazorplayground.syncfusion.com/hXVSDwLYfGJYUbyg


4 Replies 1 reply marked as answer

NP Naveen Palanivel Syncfusion Team July 30, 2025 01:36 PM UTC

Hi Ashish Khanal,

We checked your query and based on your description, it seems that you want to prevent the success message from appearing before the user confirms the action. The success message should only be shown if the user clicks "OK" in the confirmation dialog. We would like to inform you that the OnBatchSave event is triggered only after the user confirms the action by clicking "OK" in the confirmation dialog. You can use this event to display the success message. Please refer to the code snippet and the modified sample for implementation details.

UG : https://blazor.syncfusion.com/documentation/datagrid/events#onbatchsave

Sample :
https://blazorplayground.syncfusion.com/VjBejGKXTzPXNsZT

        <GridEvents RowDataBound="RowDataBoundHandler"

                    QueryCellInfo="QueryCellInfoHandler"

                    CellSelected="CellSelectHandler"

                    OnCellEdit="CellEditHandler"

                    OnBatchSave="BatchSaveHandler"

                    TValue="GridRowViewModelV2"></GridEvents>

        <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel"></GridFilterSettings>

        <GridColumns>

            <GridColumn Field="Id" IsPrimaryKey="true" Visible="false" Width="1px" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Left" />

 

@code {

    [Parameter] public DateTime AsOfDate { get; set; }

 

 

    private async Task SaveAllAsync()

    {

        // Show the confirmation dialog

        // The control should not move until the user has clicked "Ok"

        await Grid.EndEditAsync();

 

        // Get the changes and the unchanged data

        var gridData = Grid.DataSource;

        if (gridData is null) return;

 

    }

 

 

    public void BatchSaveHandler(BeforeBatchSaveArgs<GridRowViewModelV2> args)

    {

        // Show success confirmation

        ShowSuccess("All model data Saved Successfully.");

    }



Regards,
Naveen


Marked as answer

AK Ashish Khanal August 4, 2025 10:52 PM UTC

Thank you, Naveen.



NP Naveen Palanivel Syncfusion Team August 5, 2025 10:45 AM UTC

Hi Ashish Khanal,


Welcome.

Kindly get back to us if you have further queries. As always we will be assist you.


Regards,
Naveen



NP Naveen Palanivel Syncfusion Team August 5, 2025 01:35 PM UTC

Hi Ashish Khanal,


Welcome.

Kindly get back to us if you have further queries. As always we will be assist you.


Regards,
Naveen


Loader.
Up arrow icon