0

beforeSubmit在编辑选项中有一个功能。函数代码如下

beforeSubmit: function (postdata, formid) {
    var myGrid = $('#list'),
    selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
    IsIssued = myGrid.jqGrid('getCell', selRowId, 'Status');
    alert(IsIssued);
    if (IsIssued == true)
        return [false,"lll"];
    else
        return [true,"ll"];
}

但问题是这总是提交表单。我想要的是, if (IsIssued==true)然后不提交表单返回错误。否则提交表格。我得到了IsIssued成功的确切价值。

4

2 回答 2

0

最好的解决方案是按下按钮捕获点击事件并阻止默认操作,然后在您成功的情况下,提交表单:说

$('#yourButton').click(function(event)){
     event.preventDefault();
         //$.ajax({
             beforeSubmit: function (postdata, formid){
                var myGrid = $('#list'),
                selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
                IsIssued = myGrid.jqGrid('getCell', selRowId, 'Status');
                alert(IsIssued);
                if (IsIssued == true)
                    $('yourForm').submit();
                    return [false,"lll"];
                else
                   //Else you already prevented default action
                   return [true,"ll"];
           }
        //)};
     });
于 2013-11-13T05:19:34.920 回答
0

我使用了 afterShowForm 函数并隐藏了 EditForm

afterShowForm: function ()
{
var myGrid = $('#list'),
selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
IsIssued = myGrid.jqGrid('getCell', selRowId, 'Status');
if (IsIssued == 'true') {

$.jgrid.hideModal("#editmodlist");
alert("This Book Is Already Issued");
return [true];
 }
else {
return [true];
}
return [true];
}
于 2013-11-13T11:43:19.003 回答