Kendo grid row delete confimation

15,292

Solution 1

UweB is correct, you cannot hook into the destroy event. There is an example in the Kendo UI Code Library for rolling your own delete confirmation.

http://www.kendoui.com/code-library/web/grid/customize-the-delete-confirmation-dialog.aspx

The linked code example uses the Kendo Window, and gives you a way to handle the click event for both yes and no. If you just need a custom delete message, here's a code snippet:

$("#grid").kendoGrid({
    columns: [
        {
            command: [{ name: "edit" }, {
                name: "Delete", imageClass: "k-icon k-i-close", click: function (e) {
                    e.preventDefault();
                    var dataItem = this.dataItem($(e.target).closest("tr"));
                    if (confirm('Do you really want to delete my favorite record?')) {
                        var dataSource = $("#grid").data("kendoGrid").dataSource;
                        dataSource.remove(dataItem);
                        dataSource.sync();
                    }
                }
            }], title: " ", width: "200px"
        }
    ]
});

Solution 2

I don't believe it is possible to catch these, the destroy event is built-in and works "as-is".

However, there's the click event (http://docs.kendoui.com/api/web/grid#configuration-columns.command.click) where you can create a custom command that displays a confirmation dialogue that you have to write (could e.g. use the javascript built-in confirm() which doesn't look pretty, but will work for now), where you have full control over the buttons and events they fire.

Share:
15,292
jestges
Author by

jestges

Updated on June 17, 2022

Comments

  • jestges
    jestges almost 2 years

    Hi I've a Kendo grid with delete button on each row. When I click on delete button it is asking for confirmation like "Delete?" up to here it is fine. Now I want to catch the events when I click on yes or now.

    When I click yes want to display a message. And when I click No I want to display another message.

    How to catch these events in Kendo?

  • jestges
    jestges almost 11 years
    Hey I got it.. var check = confirm("Are you sure?"); if (check) {} this is working for me