How to close the "are you sure you want to cancel " dialog

In the method for OnSave for when I update my grid, I also need to save the results to the database.  If there is an error, I return that and need to cancel all batch edit changes.  I set Args.cancel to true and to close the gridedit.  But it a pop up asking if I want to confirm this comes up.  I don't want this to show, I basically just want to cancel the changes and refresh the grid to what it was before without any pop ups.  How can I do this?
 public async void OnSave(BeforeBatchSaveArgs<FDIChemicalOrderLine> Args)
    {

 if (error){
            Args.Cancel = true;

            GridInstance.CloseEdit();
}
}

3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team October 2, 2020 12:13 PM UTC

Hi Chris, 

Greetings from Syncfusion support. 

You can prevent the showing of Batch Confirmation dialog by setting the ShowConfirmDialog property of GridEditSettings to false. Please refer the below documentation for more details, 

Please add the below highlighted property in your application, 

 
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ShowConfirmDialog="false" ... Mode="EditMode.Batch"></GridEditSettings> 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



CJ chris johansson October 2, 2020 03:33 PM UTC

Yes I understand that at the grid level but that affects all pop ups.. I would like to have the usual ones that pop up to save etc.. but when it fails to save from the database stand point and i call args.cancel and grid.closeedit() to refresh the grid to the original, Thats the point when i don't want the "are you sure you want to cancel" because i'm forcing it to cancel due to a database failure.  Is it an all or nothing type thing?


VN Vignesh Natarajan Syncfusion Team October 5, 2020 01:03 PM UTC

Hi Chris,  
 
Query: “Is it an all or nothing type thing? 
 
We have analyzed your query and we suggest you to achieve your requirement by using ShowConfirmDialog property of GridEditSettings. We suggest you to change the property value from Grid instance (reference) while calling the CloseEdit() method of Grid.  
 
Refer the below code example.  
 
<SfButton OnClick="Cancel" Content="Cancel"></SfButton> 
  
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add""Delete""Update""Cancel" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings> 
    <GridColumns> 
. . . . . . 
    </GridColumns> 
</SfGrid> 
  
@code{ 
    SfGrid<Order> Grid { getset; } 
    public List<Order> Orders { getset; } 
    public bool enable { getset; } = true; 
    public void Cancel() 
    { 
        Grid.EditSettings.ShowConfirmDialog = false// to disbale the warning 
        StateHasChanged(); 
        Grid.CloseEdit(); // to closing the editing form 
        Grid.EditSettings.ShowConfirmDialog = true// enable the warning  
        StateHasChanged(); 
    } 
 
Please find the sample which we have prepared using above solution from below  
 
 
Kindly get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon