您好我通过格式化操作获得了jqgrid编辑功能。是否可以在提交之前使用该方法并执行验证。
formatoptions: {
keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing.
onEdit: function (rowid) {
//alert("in onEdit: rowid=" + rowid + "\nWe don't need return anything");
},
onSuccess: function (jqXHR) {
$('input[id*="gs_"]').val("");
$grid.setGridParam({ search: false, postData: { "filters": ""} ,datatype: 'json'}).trigger("reloadGrid");
// the function will be used as "succesfunc" parameter of editRow function
// (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
/*alert("in onSuccess used only for remote editing:" +
"\nresponseText=" + jqXHR.responseText +
"\n\nWe can verify the server response and return false in case of" +
" error response. return true confirm that the response is successful");
// we can verify the server response and interpret it do as an error
// in the case we should return false. In the case onError will be called
return true;*/
},
onError: function (rowid, jqXHR, textStatus) {
// the function will be used as "errorfunc" parameter of editRow function
// (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
// and saveRow function
// (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow)
/*alert("in onError used only for remote editing:" +
"\nresponseText=" + jqXHR.responseText +
"\nstatus=" + jqXHR.status +
"\nstatusText" + jqXHR.statusText +
"\n\nWe don't need return anything");*/
},
afterSave: function (rowid) {
//alert("in afterSave (Submit): rowid=" + rowid + "\nWe don't need return anything");
},
afterRestore: function (rowid) {
//alert("in afterRestore (Cancel): rowid=" + rowid + "\nWe don't need return anything");
},
delOptions: myDelOptions
}
} ],
该功能永远不会被解雇。我希望针对验证目的执行ajax请求,
Kidnly提供帮助和谢谢
答案 0 :(得分:2)
内联编辑中有beforeSaveRow
(如果您不使用某些旧版本的jqGrid)。无法在formatoptions
的{{1}}内设置回调,但您可以改为使用formatter: "actions"
:
$.jgrid.inlineEdit