The second parameter of delGridRow
is an object with options, so you can do like following
jQuery('#category_grid').delGridRow(rows,{
errorTextFormat: function (data) {
if (data.responseText.substr(0, 6) == "<html ") {
return jQuery(data.responseText).html();
}
else {
return data.responseText;
// or
// return "Status: '" + data.statusText + "'. Error code: " +data.status;
}
}
});
The text retText
, which you give back by errorTextFormat
function will be placed in the corresponding div
of the error message with respect of jQuery.html(retText)
code inside of delGridRow
function.
By the way I don't call delGridRow
function directly. Instead of that if I add the navigation bar to the jqGrid with respect of navGrid
function, I gives my errorTextFormat
function as a parameter to standard "Delete button". To be exact I do this with respect of $.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) == "<html ") {
return jQuery(data.responseText).html();
}
else {
return "Status: '" + data.statusText + "'. Error code: " + data.status;
}
}
});
(the real code of my errorTextFormat
looks like a little more complex, but the idea of usage is the same).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…