从服务器返回一些错误时,再次重置并以可编辑模式保存JqGrid行的数据 [英] Reset again and persist the data of JqGrid Row in Editable mode when some error return from Server

查看:79
本文介绍了从服务器返回一些错误时,再次重置并以可编辑模式保存JqGrid行的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 var editparameters= {
                    "keys": true,
                    "oneditfunc": function () {
                        debugger;
                        $("select#" + arrprimarykey + "_StateName").val(rowData.StateCode);
                    },
                    "successfunc": function (data) {
                        debugger;
                        var msg = JSON.parse(data.responseText).Message;
                        var msgType = JSON.parse(data.responseText).MsgType;
                        if (msgType == "S") {
                            alert(msg);
                            $(CityMaster.idGrid).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
                        } else {
                            alert(msg)
                           HERE RESTORE TO INLINE EDITABLE MODE THE ROW ,AGAIN IF ERROR RETURN FROM SERVER
                        }
                    },

                    "url": CityMaster.EditUrl,
                    "extraparam": {},
                    "aftersavefunc": function (data) {
                        debugger;
                    },
                    "errorfunc": null,
                    "afterrestorefunc": function (data) {
                        debugger;
                        $(CityMaster.idGrid).jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
                    },
                    "restoreAfterError": true,
                    "mtype": "POST"
                }
                jQuery(CityMaster.idGrid).jqGrid('editRow', arrprimarykey, editparameters);

在"successfunc"中,else部分应将行保留为可编辑模式...

In "successfunc" the else part should retain the row in editable mode ...

推荐答案

在jqGrid中报告错误的标准方法是设置HTTP响应的错误状态代码.例如,如果使用内联编辑,则if将强制执行errorfunc.如果服务器代码无法设置HTTP响应的错误状态代码,则jqGrid提供了替代方法.回调successfunc可用于检查服务器的响应. successfunc应该通知jqGrid现在响应是否成功.如果成功响应,则回调successfunc应该返回数组[true],并返回包含两个元素的数组:如果出现错误,则返回[false, "error message to display the user"].回调successfunc通常从服务器的响应中获取错误消息.

The standard way of reporting the error in jqGrid is setting an error status code of HTTP response. If will force executing of errorfunc for example in case of usage inline editing. If the server code unable to set error status code of HTTP response then jqGrid provides an alternative. The callback successfunc can be used to examine the response of the server. The successfunc should inform jqGrid whether the response is successful of now. The callback successfunc should return array [true] in case of successful response and return array with two elements: [false, "error message to display the user"] in case of the error. The callback successfunc get typically the error message from the response from the server.

更新:在开始内联编辑之前,您应使用restoreAfterError: false(请参见当前代码中的"restoreAfterError": true)来防止恢复行的状态.

UPDATED: You should of case use restoreAfterError: false (see "restoreAfterError": true in your current code) to prevent restoring the state of the row before starting inline editing.

这篇关于从服务器返回一些错误时,再次重置并以可编辑模式保存JqGrid行的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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