I want to check before showing add form in jqgrid
that variable myVar
has value. Following is my code in add option to check whether myVar
has value or not. If myVar
is null then I don't want add form to be open.
}).navGrid('#mypager',{cloneToTop:true, edit:false,add:true,del:false,view:false,search: false,refresh:true},
{},
{
beforeShowForm : function (formid)
{
if(myVar.length==0)
{
alert("Value can't be blank!");
return[false,"Value can't be blank!"];
}
},
recreateForm: true,
reloadAfterSubmit:true,
closeOnEscape:true,
modal:true,
jqModal: false,
savekey: [true,13],
width:550,
mtype:'POST',
url: 'MyServlet',
editData:{action:'ListInsert',myVar: function () {return myVar;}},
afterSubmit: function (response)
{
var myInfo = '<div class="ui-state-highlight ui-corner-all">'+'<span class="ui-icon ui-icon-info" '+'style="float: left; margin-right:.3em;"></span>'+ response.responseText +'</div>';
$infoTr = $("#TblGrid_" + $.jgrid.jqID(this.id) + ">tbody>tr.tinfo"),$infoTd = $infoTr.children("td.topinfo");
$infoTd.html(myInfo);
$infoTr.show();
return [true, "", ""];
},
errorTextFormat: function (response)
{
return '<span class="ui-icon ui-icon-alert" ' +'style="float:left; margin-right:.3em;"></span>' +response.responseText;
}
},
Above code shows the alert, but still shows the add form.
myVar
contains id from other grid and If myVar
doesn't have value then I don't want to show add form.
Thanks in advance.