This is a migrated thread and some comments may be shown as answers.

Default behavior for the Remove Event

1 Answer 561 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 22 Oct 2013, 06:39 PM
Is the default behavior for the grid to remove row before firing the remove event?  If so is there a beforeRemove event I can use?

I'm trying to implement my own confirm, for deleting.  I have seen some of the other examples on here but I would prefer to write as little
custom code as possible since there will be a lot of grids in my project that will all use this functionality.

so far I have this
 $kendoGrid.bind("remove", gridRemoveRow);

 var gridRemoveRow = function (e) {
                e.preventDefault();
                app.showMessage("Are you sure you want to delete this row?", "Delete Row", ["Yes", "No"]).then(function (result) {
                    if (result == "Yes") {
                        $kendoGrid.dataSource.remove(e.model)
                        $kendoGrid.dataSource.sync()
                    }
                    else
                        $kendoGrid.cancelChanges();
                });
            };

This code works, but the behavior of removing the row before it gets to gridRemoveRow  could cause some confusion for the user with thinking they clicked the wrong row or that the delete already happened.

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 24 Oct 2013, 09:01 AM
Hello Tyler,

You can create a custom delete button via template, and then call the removeRow() method of the Kendo UI Grid. A pretty neat code example with similar functionality, is uploaded on the following link:

http://www.kendoui.com/code-library/web/grid/customize-the-delete-confirmation-dialog.aspx
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Tyler
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or