【问题标题】:How to ask for confirmation before update data using KendoUI Grid with ODATA type?如何在使用 ODATA 类型的 KendoUI Grid 更新数据之前要求确认?
【发布时间】:2018-03-25 14:16:38
【问题描述】:

当我单击剑道网格编辑弹出表单的更新按钮时,我需要请求确认(确认对话框)。问题是使用 ODATA,我指定了 kendoGridConfiguration.dataSource.transport.options.update.url,并且我不能引入任何异步逻辑作为确认消息。你能帮帮我吗?

如果我想使用 odata 确认从网格中删除元素,也会发生同样的情况。

谢谢!

【问题讨论】:

  • 我个人不使用 ODATA,但为了完成我认为您正在尝试做的事情,我只是向 jquery 添加了一个 if 语句,即 if (confirm('Are you sure you want to delete this record?')) { YOUR_FUNCTION_FOR_DELETE_HERE },这就是我目前使用的在将删除发送到数据库之前确认用户想要删除某些内容

标签: kendo-ui kendo-grid odata confirmation kendo-datasource


【解决方案1】:

我在这里创建了一个DEMO,在更新记录之前会要求用户确认,并且只有在用户同意的情况下才会编辑记录。

我已绑定网格的save 事件并添加代码以在编辑操作继续之前要求确认。

这是来自 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();
                                    }
                                }
                          }
.......
.....

【讨论】:

  • 是的,这就是这样做的方法,使用网格的保存事件并在确认取消的情况下执行 preventdefault。非常感谢拉胡尔!
  • 别担心,伙计!很高兴帮助你:)
  • 对你的问题的 UP,如果你能 UP 投票给我的答案,那就太好了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-16
  • 2015-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多