用于显示服务器端验证结果的 Jqgrid 编辑事件

Jqgrid edit event for displaying server side validation result

本文关键字:Jqgrid 编辑 事件 结果 显示 服务器端 验证 用于      更新时间:2023-09-26

我正在使用内联编辑和删除功能。我没有明确使用任何editGridRowdelGridRow方法。我需要在服务器端验证数据并显示结果。在删除的情况下,我在delOptions属性下有很多事件,例如afterSubmitafterComplete。但是对于编辑,我不知道应该使用什么事件来从服务器获取验证结果并将其显示给用户。建议?

//My action colmodel
colEditModel = {
            name: "actions",
            width: 90,
            formatter: "actions",
            sortable: false,
            search: false,
            formatoptions: {
                keys: true,
                editOptions: {},
                addOptions: {},
                delOptions: {
                    onclickSubmit: function (options) {
                        options.delData = {//Some data};
                        options.url = "Allocation/EditAllocation";
                    },
                }
            }
        };
// Grid
$("#jqGrid").jqGrid({
            url: "Allocation/GetAllocations",
            mtype: "GET",
            datatype: "json",
            colModel: col_model,
            colNames: col_names,
            postData: { selectedDate: dateValue, filterCriteria: criteria },
            editurl: "Allocation/EditAllocation",
            serializeRowData: function (postdata) {
                var requestData = { // some data};
                return requestData;
            },
            loadonce: true,
            viewrecords: false,
            height: 330,
            width: null,
            shrinkToFit: false,
            autoheight: true,
            pager: "#jqGridPager",
            scroll: false,
            rownumbers: false,
            treeGrid: false,
            gridview: true,
        });

你使用的jqGrid版本和你使用的jqGrid分支的确切实现。如果您使用旧版本的 jqGrid,则可以在formatter: "actions" formatoptions内指定onError回调来处理内联编辑的错误并使用delOptions.errorTextFormaterrorTextFormat回调,您必须在 formatoptionsdelOptions 属性中定义)。

请务必了解,服务器端验证与服务器报告的任何其他错误相同。服务器应以 HTML 片段的形式返回错误描述。响应必须使用任何错误的 HTML 状态代码(值>=400)。