Can you add a confirmation popup to the grid row delete like what is in the JQuery UI library?
---
ADMIN EDIT
As of 2.23.0 predefined confirmation dialog is available for use with just a few lines of code and you can achieve that behavior through the OnClick event of the command button:
<TelerikGrid Data=@GridData EditMode="@GridEditMode.Inline"
Height="500px" AutoGenerateColumns="true" Pageable="true"
OnDelete="@DeleteItem">
<GridColumns>
<GridAutoGeneratedColumns />
<GridCommandColumn Width="100px">
<GridCommandButton Command="Delete" Icon="delete" OnClick="@ConfirmDelete">Delete</GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
@code {
//for the confirmation - see the OnClick handler on the Delete button
[CascadingParameter]
public DialogFactory Dialogs { get; set; }
async Task ConfirmDelete(GridCommandEventArgs e)
{
Product productToDelete = e.Item as Product;
string confirmText = $"Are you sure you want to delete {productToDelete.Name}?";
string confirmTitle = "Confirm Deletion!";
//the actual confirmation itself
bool userConfirmedDeletion = await Dialogs.ConfirmAsync(confirmText, confirmTitle);
e.IsCancelled = !userConfirmedDeletion;//cancel the event if the user did not confirm
}
// only sample data operations follow
public List<Product> GridData { get; set; }
protected override async Task OnInitializedAsync()
{
GridData = Enumerable.Range(1, 50).Select(x => new Product { Id = x, Name = $"Name {x}" }).ToList();
}
private void DeleteItem(GridCommandEventArgs args)
{
Console.WriteLine("DELETING ITEM");
var argsItem = args.Item as Product;
GridData.Remove(argsItem);
}
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
}
---