Reset again and persist the data of JqGrid Row in Editable mode when some error return from Server

放肆的年华 提交于 2019-12-12 06:44:47

问题


enter image description hereIn "successfunc" the else part should retain the row in editable mode ...

 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);

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/33297270/reset-again-and-persist-the-data-of-jqgrid-row-in-editable-mode-when-some-error

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