不要提交for before usingSubmit功能

时间:2013-11-13 05:05:08

标签: jqgrid

我在编辑选项中有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的确切值。

2 个答案:

答案 0 :(得分: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"];
           }
        //)};
     });

答案 1 :(得分: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];
}