delGridRow的第二个参数是带有选项的对象,因此您可以执行以下操作
jQuery('#category_grid').delGridRow(rows,{
errorTextFormat: function (data) {
if (data.responseText.substr(0,6) == "
return jQuery(data.responseText).html();
}
else {
return data.responseText;
// or
// return "Status: '" + data.statusText + "'. Error code: " +data.status;
}
}
});
您通过errorTextFormat函数返回的文本retText将放置在delGridRow函数内的jQuery.html(retText)代码的错误消息的相应div中.
顺便说一句,我不直接调用delGridRow函数.而不是如果我将导航栏添加到jgGrid关于navGrid函数,我将errorTextFormat函数作为参数提供给标准的“删除按钮”.确切地说,我是关于$.jgrid.del这样做的:
jQuery.extend(jQuery.jgrid.del,{
ajaxDelOptions: { contentType: "application/json" },mtype: "DELETE",reloadAfterSubmit: false,jqModal: false,serializeDelData: function (postdata) {
return "";
},errorTextFormat: function (data) {
if (data.responseText.substr(0,6) == "
return jQuery(data.responseText).html();
}
else {
return "Status: '" + data.statusText + "'. Error code: " + data.status;
}
}
});
(我的errorTextFormat的真实代码看起来有点复杂,但使用的想法是一样的).