Problem getting delete confirmation working correctly

Hi there,

I have a DataGrid setup in my project (ASP.NET Core with EJ2 library) with a delete button added via <e-grid-columns> commands property. I want to confirm the deletion before going ahead with it. I added an <e-grid-editsettings> tag with the showDeleteConfirmDialog setup true. When I click the Delete button, the confirmation dialog appears but the deletion goes ahead before I even click on anything.

The grid is setup like this:

<e-grid-editsettings allowDeleting="true" showDeleteConfirmDialog="true"></e-grid-editsettings>
...
if (Model.HasDelete)
{
    commands.Add(new
    {
        type = "Delete",
        buttonOption = new
        {
            iconCss = "e-icons e-delete",
            cssClass = "e-flat",
            id = "DeleteBtn"
        }
    });
}
...
<e-grid-column textAlign="Center" width="120" allowFiltering="false" commands="commands"></e-grid-column>

Any ideas? Am I setting up the delete functionality wrong?

Thanks in advance,
Jason

3 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team June 10, 2020 12:32 PM UTC

Hi Jason, 

Greetings from syncfusion support 

Based on your query we have prepared a sample of Grid with command column and we able to display the dialog when we click on delete icon in the command column.  

When we click on ok button in the confirmation dialog then the records get deleted. It works fine from our end.  

Please refer the below code example ,sample and video demo for more information. 

Index.cshtml 
 
@{ 
 
    List<object> commands = new List<object>(); 
    commands.Add(new { type = "Delete", buttonOption = new { iconCss = "e-icons e-delete", cssClass = "e-flat" } }); 
 
} 
 
<div> 
    <ejs-grid id="Grid" dataSource="ViewBag.dataSource" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true"> 
        <e-grid-editSettings allowAdding="true" showDeleteConfirmDialog="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings> 
        <e-grid-pagesettings pageSize="8"></e-grid-pagesettings> 
        <e-grid-columns> 
            .  .  .  .  .  . . 
           <e-grid-column headerText="Command buttons" width="150" commands="commands"></e-grid-column> 
        </e-grid-columns> 
    </ejs-grid> 
</div> 



If you still face the issue, please share the below details that will be helpful for us to provide better solution 

1. Share the complete grid code example. 

2. Please share your syncfusion package version. 

3. If possible please replicate the issue with our above attached sample. 

Regards,
Rajapandi R


Marked as answer

JA Jason June 10, 2020 01:39 PM UTC

Okay, I figured out what the problem was. The person I inherited this grid code from had some custom button handling that was bypassing the built-in confirmation handling.

Thanks for the help!
Jason


RR Rajapandi Ravi Syncfusion Team June 11, 2020 01:04 PM UTC

Hi Jason, 

We are happy to hear our suggested solution was working with your end. 

Please get back to us if you need further assistance. 
 
Regards, 
Rajapandi R 


Loader.
Up arrow icon