Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ask for confirmation before update data using KendoUI Grid with ODATA type?

I need to ask for a confirmation (a confirm dialog), when i click the update button of the kendo grid edit popup form. The problem is that using ODATA, i specify the kendoGridConfiguration.dataSource.transport.options.update.url, and i cant introduce any async logic as a confirmation message. Can you help me?

The same would happen if I wanted to confirm a deletion of an element from the grid using odata.

Thanks!

like image 881
Alejandro M. Pi Cano Avatar asked Oct 18 '22 04:10

Alejandro M. Pi Cano


1 Answers

I have created a DEMO here in which the user would be asked for confirmation before updating the record and the record will only be get edited if the user would agree.

I have bound the save event of the grid and added code to ask for confirmation before the edit action proceeds.

Here is the code from the DEMO.

.....
.......
//On click of POPUP form Update button
                          save: function(e) {
                                //check if the row is being edited and not newly added
                                if (! e.model.isNew())
                                {
                                    if (! confirm("Are you really sure that you want to update the data ?")) 
                                    {
                                        //In the confirm box, if the user clicks no or cancel, then do not proceed with the updation of record
                                        e.preventDefault();
                                    }
                                }
                          }
.......
.....
like image 170
Rahul Gupta Avatar answered Oct 21 '22 00:10

Rahul Gupta