我正在使用jqGrid。
这是我的代码:
$("#list").jqGrid({
url:'urlone.php',
editurl:'somepage.php',
datatype: 'json',
mtype: 'POST',
colNames:['ID','Name'],
colModel :[
{name:'cid', index:'cid'},
{name:'name', index:'name'}
],
"postData":{"oper":"grid"},
"prmNames":{"query":"grid"},
pager: '#pager'
}).navGrid('#pager', {"edit":true,"add":true,"del":false,"search":false,"refresh":true,"view":false,edittitle: "Edit Candidate",addtitle: "Add Candidate",deltitle: "Delete Candidates",searchtitle: "Search Candidates",refreshtitle: "Refresh Data",viewtitle: "View Candidate",edittext: "Edit",addtext: "Add",deltext: "Delete",searchtext: "Search",refreshtext: "Refresh",viewtext: "View"},
prmEdit,prmAdd);
prmEdit = {
"drag":false,"resize":false,"closeOnEscape":true,"dataheight":430,"datawidth":450,"width":500,"errorTextFormat":function(r){ return r.responseText;},"closeAfterEdit":true,viewPagerButtons:false,"editCaption":"Update Candidate",reloadAfterSubmit:true,recreateForm:true
,beforeShowForm: function($form) {
$form.parent().find('.EditButton').prepend('<a href="javascript:void(0)" id="qButton" class="fm-button ui-state-default ui-corner-all fm-button-icon-left">Update & Qualify<span class="ui-icon ui-icon-flag"></span></a>');
},beforeSubmit : function(postdata, formid){
$.ajaxFileUpload({
url: 'uploadResume.php?id='+postdata.cid+'&cname='+postdata.name,
secureuri:false,
fileElementId:'resume',
dataType: 'json',
success: function (data, status) {
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else{
alert(data.msg);
}
}
return[true,"Resume successfuly uploaded"];
},
error: function (data, status, e)
{
return[false,e];
}
});
return[true,"Resume not uploaded"];
}, afterComplete : function (response, postdata, formid) {
var txt = '{"responseT":['+response.responseText+']}';
var obj = eval ("(" + txt + ")");
if(obj.responseT[0].msg == null) msgStr = "Undefined Error, Contact Admin!";
else msgStr = obj.responseT[0].msg;
openmsgbox(obj.responseT[0].err,msgStr);
}
};
prmAdd = { "drag":false,"resize":false,"closeOnEscape":true,"dataheight":430,"datawidth":450,"width":500,"errorTextFormat":function(r){ return r.responseText;},"closeAfterAdd":true,viewPagerButtons:false,"addCaption":"Add Candidate","bSubmit":"Add",reloadAfterSubmit:true,recreateForm:true, beforeSubmit : function(postdata, formid){
$.ajaxFileUpload({
url: 'uploadResume.php?id='+postdata.cid+'&cname='+postdata.name,
secureuri:false,
fileElementId:'resume',
dataType: 'json',
success: function (data, status) {
if(typeof(data.error) != 'undefined')
{
if(data.error != '')
{
alert(data.error);
}else{
alert(data.msg);
}
}
return[true,"Resume successfuly uploaded"];
},
error: function (data, status, e)
{
return[false,e];
}
});
return[true,"Resume not uploaded"];
}, afterComplete : function (response, postdata, formid) {
var txt = '{"responseT":['+response.responseText+']}';
var obj = eval ("(" + txt + ")");
if(obj.responseT[0].msg == null) msgStr = "Undefined Error, Contact Admin!";
else msgStr = obj.responseT[0].msg;
openmsgbox(obj.responseT[0].err,msgStr);
}
};
我在编辑表单中添加了一个名为“Update&amp; Qualify”的自定义按钮。现在当用户点击默认提交按钮时,表单应该使用现有的editurl提交,但是当点击“Update&amp; Qualify”按钮时,“editurl”的值应该改为“somepage.php?do = qualify”和表格应该提交...但我无法弄清楚如何...任何人都可以帮助我吗?
答案 0 :(得分:0)
要将点击从新按钮转发到原始“提交”按钮,您可以使用以下行附加beforeShowForm
的代码
$("#qButton").click(function () {
$("#sData").click();
});
此外,您可以在click
处理程序中设置任何变量并测试变量,以区分提交和新提示与原始“提交”按钮的提交。
在onclickSubmit回调内,您可以更改url
属性:
onclickSubmit: function (params, posdata) {
// first test something and then change the URL with
params.url = "newUrl";
}