来自服务器端异常的jqGrid错误消息 [英] jqGrid error message from server side exception

查看:81
本文介绍了来自服务器端异常的jqGrid错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为jqgrid添加了以下代码:

I've added the following code for my jqgrid:

changeTextFormat = function (data) {

                return "Activity or one from the same price group already used";
            };
            jQuery.extend(jQuery.jgrid.edit, {errorTextFormat: changeTextFormat })

它非常适合插入,并且在对话框顶部显示错误消息.

It works great for insert and I get the error message appearing in the top of the dialog.

但是,对于编辑而言,效果并不理想.而是出现了一个带有错误消息的大型对话框.

However for edits it's not working so well. Instead a massive dialog is appearing with the error message.

我目前正在考虑这是因为我正在使用内联编辑,因此它必须弹出一个全新的对话框.有没有一种方法可以更好地格式化此对话框.我非常确定,对于内联编辑,在出现异常后甚至没有通过changeTextFormat运行.

I'm currently thinking that it's because I'm using inline editing so it has to pop up a whole new dialog. Is there a way to format this dialog better. I'm pretty sure that for the inline edits it's not even running through changeTextFormat after an exception.

推荐答案

是正确的.通过更改jQuery.jgrid.edit,您可以仅设置 errorTextFormat 用于表单编辑.如果使用内联编辑,则必须使用

It's correct. By changing of jQuery.jgrid.edit you set errorTextFormat only for the form editing. In case of the usage inline editing you have to use errorfunc parameter of the editRow.

您可以轻松地看到 errorTextFormat 和errorfunc参数.如果在errorTextFormat中应该返回将在错误消息中使用的错误消息,则回调函数errorfunc应该 display 相应的错误消息本身.如果要使错误对话框的外观相同,可以使用$.jgrid.info_dialog方法.在答案您可以找到相应的代码片段.另请参见代码片段的jqGrid源代码.

You can easy see the difference between errorTextFormat and errorfunc parameter. If in the errorTextFormat you should return the error message which will be used in the error message, the callback function errorfunc should display the corresponding error message itself. If you want to have the same look of the error dialog you can use $.jgrid.info_dialog method. In the answer you could find the corresponding code fragment. See additionally the code fragment of the jqGrid source code.

这篇关于来自服务器端异常的jqGrid错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆