【问题标题】:Prevent two save calls on cell edit when I enter for save [closed]当我输入保存时,防止在单元格编辑时进行两次保存调用[关闭]
【发布时间】:2021-03-13 05:25:31
【问题描述】:

两次调用 jqgrid 中的保存单元格 url(一次是在输入的情况下,这是 jqgrid 的默认行为)另一种是在 focusout 时自定义保存。

当我输入保存时,我需要防止两次保存单元格编辑调用。

column.editoptions.dataEvents = [{
  type: 'keyup focusout',
  fn: function(e) {
    var isValidate = ValidateGridEmail($(this).val());
    EmailValidationMessage(isValidate);
    if (e.type == "focusout" && isValidate && globalVar.irow != null && globalVar.icol != null) {
      $("#GridEditConfiguration").saveCell(globalVar.irow, globalVar.icol);

      globalVar.irow = null;
      globalVar.icol = null;
    }
  }
}]

【问题讨论】:

    标签: javascript jquery jqgrid free-jqgrid


    【解决方案1】:

    你可以使用一些事件来做到这一点,但我不确定 free-jqGrtid 有这些。这是不支持的版本。

    在受支持的Guriddo jqGrid 中,您可以使用 beforeSaveCell 发出开始保存的信号,然后在您的情况下使用它。将 afterSubmitCell 中的信号设置回 false。

    像这样:

    var savestart = false;   
    $("#jqGrid").jqGrid({
        beforeSubmitCell : function( id, name, val, irow,icol) {
            savestart = true;
        },
        afterSubmitCell : function() {
            savestart = false; 
            return [true,""];
        },
        ....
     });
    

    在你的代码中添加这个

    if (e.type == "focusout" && isValidate && globalVar.irow != null && globalVar.icol != null && !savestart) {
      $("#GridEditConfiguration").saveCell(globalVar.irow, globalVar.icol);
      ...
    }
    

    你应该再次检查这些事件是否在 free-jqGrid 中可用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      相关资源
      最近更新 更多