This example demonstrates how to create a custom Delete button and show a confirmation pop-up window on a button click.
Create a custom Delete button and handle the grid's CustomButtonClick event to show a confirmation pop-up window on a button click.
GridViewCommandColumnCustomButton customButton = new GridViewCommandColumnCustomButton(){
ID = "deleteButton", Text = "Delete" };
settings.CommandColumn.CustomButtons.Add(customButton);
settings.ClientSideEvents.CustomButtonClick = "function(s, e) { OnCustomButtonClick(s, e); }";
var visibleIndex;
function OnCustomButtonClick(s, e) {
if (e.buttonID = "deleteButton") {
visibleIndex = e.visibleIndex;
popup.Show();
}
}
When a user clicks the Yes button, the grid deletes the row specified by its visible index.
function OnClickYes(s, e) {
GridView.DeleteRow(visibleIndex);
popup.Hide();
}
function OnClickNo(s, e) {
popup.Hide();
}
- GridViewPartial.cs (VB: GridViewPartial.vb)
- Index.cs (VB: Index.vb)
- HomeController.cs (VB: HomeController.vb)
(you will be redirected to DevExpress.com to submit your response)