在jqGrid中显示自定义表单上的错误和消息
我试图实现的是,在对话框窗体上显示询问和回答的消息。然而,尽管上面的示例在代码中使用了默认的editGridRow,但我有一个通过JSON加载的自定义对话框表单。例如,返回的JSON错误/验证消息可能是:在jqGrid中显示自定义表单上的错误和消息,jqgrid,Jqgrid,我试图实现的是,在对话框窗体上显示询问和回答的消息。然而,尽管上面的示例在代码中使用了默认的editGridRow,但我有一个通过JSON加载的自定义对话框表单。例如,返回的JSON错误/验证消息可能是: {"CustomerName":{"isEmpty":"\u201cthis value is - not to be left empty.\u201d"}} 我需要能够将它们输出为对话框表单顶部的“客户名称-此值不能为空” 我已经在中尝试了这些解决方案,但我还无法对它们进行自定义,使其在
{"CustomerName":{"isEmpty":"\u201cthis value is - not to be left empty.\u201d"}}
我需要能够将它们输出为对话框表单顶部的“客户名称-此值不能为空”
我已经在中尝试了这些解决方案,但我还无法对它们进行自定义,使其在我的场景中工作
我有这样一个函数调用:
function LaunchEditForm(dialog)
{
$('form', dialog).submit(function ()
{
$.ajax({
url: '/customer/update-customer/',
type: this.method,
reloadAfterSubmit: true,
data: $(this).serialize(),
success: function (result)
{
if (result.success)
{
console.log(result);
//can I call a function here to prepend modal form
//with success message? how please?
}
else
{
console.log(result);
// can I prepend the dialog to show model errors here?
//var errorDetail = jQuery.parseJSON(result.responseText);
}
}
});
return false;
});
}
我尝试过使用后提交如下:
afterSubmit: function (response, postdata)
{
if (response.responseText == "Success")
{
jQuery("#success").show();
jQuery("#success").html("Customer successfully updated");
jQuery("#success").fadeOut(6000);
return [true, response.responseText]
}
else
{
return [false, response.responseText]
}
}
errorTextFormat: function (data)
{
if (data.responseText.substr(0, 6) == "<html ")
{
return jQuery(data.responseText).html();
}
else
{
return "Status: '" + data.statusText + "'. Error code: " + data.status;
}
}
这还没有奏效——也许我把它放在了另一个范围内
还尝试了errorTextFormat,如下所示:
afterSubmit: function (response, postdata)
{
if (response.responseText == "Success")
{
jQuery("#success").show();
jQuery("#success").html("Customer successfully updated");
jQuery("#success").fadeOut(6000);
return [true, response.responseText]
}
else
{
return [false, response.responseText]
}
}
errorTextFormat: function (data)
{
if (data.responseText.substr(0, 6) == "<html ")
{
return jQuery(data.responseText).html();
}
else
{
return "Status: '" + data.statusText + "'. Error code: " + data.status;
}
}
errorTextFormat:函数(数据)
{
if(data.responseText.substr(0,6)=”