jqGrid error message from server side exception

天涯浪子 提交于 2019-12-23 02:13:07

问题


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.

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/7816119/jqgrid-error-message-from-server-side-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!