1

i would like to ask how i can intercept the ajax delete functionality of a grid using ajax binding? specifically, up to the point wherein, after i click on delete, as the confirm prompt pops up, i would like to do something based on the user's choice,

basically, if OK, do this, if CANCEL do that..

2 Answers 2

2

You need to use the OnRowDataBound and attach a click handler to the delete button. Then you can display custom confirmation and decide what to do. If you want' to prevent the grid deletion code - call e.stopPropagation(). Here is a quick sample:

<%: Html.Telerik().Grid(Model)
        // Prevent the grid from displaying the default delete confirmation
        .Editable(editing => editing.DisplayDeleteConfirmation(false))
        // Subscribe to the OnRowDataBound event
        .ClientEvents(e => e.OnRowDataBound("onRowDataBound"))
%>
<script>
function onRowDataBound(e) {
   $(e.row) // get the current table row (TR) as a jQuery object
      .find(".t-grid-delete") // find the delete button in that row
      .click(function(e) {  // handle its "click" event
          if (confirm("Do you want to delete this record?")) {
             // User clicked "OK"
          } else {
             // User clicked "Cancel"
             e.stopPropagation(); // prevent the grid deletion code from executing.
          }
      });
}
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

The demo page seems to contain an example of what you are looking for.

1 Comment

Thanks Darin, i will look into that now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.