jqgrid:editData 未发送到服务器

jqgrid: editData not being sent to server

我正在使用 guriddo jqGrid 5.2.1

我遵循了对这些问题的回答:

但是我定义的 editData 没有发送到端点。

这是我的 jqgrid 寻呼机定义中的代码:

$('#jqGrid').navGrid('#jqGridPager',
            // the buttons to appear on the toolbar of the grid
            { edit: true, 
                add: true, 
                del: true, 
                search: false, 
                refresh: false, 
                view: false, 
                position: "left", 
                cloneToTop: false,
                mtype: 'POST',
                editData: {
                    mediaPlanId : function() { return mpId; }
                }},
            // options for the Edit Dialog
            {
                editCaption: "Edit Item",
                recreateForm: true,
                checkOnUpdate : true,
                checkOnSubmit : true,
                closeAfterEdit: true,
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            },
            // options for the Add Dialog
            {
                closeAfterAdd: true,
                recreateForm: true,
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            },
            // options for the Delete Dailog
            {
                errorTextFormat: function (data) {
                    return 'Error: ' + data.responseText;
                }
            }

    );

mpId 是在页面级别的 jqGrid 和 jqGridPager 函数之外定义的。我尝试发送值 1,但这也不起作用。我怀疑我错过了一些简单的东西,但我不知道是什么。

您将 editData 参数放在了错误的位置。 navGrid 的选项非常糟糕,很容易出错。我在我开发的 the wiki article of free jqGrid fork 中详细描述了这个问题。

目前你把editData放在navGrid的选项里,而不是放在Edit/Add的选项里,也就是editGridRow. The problem is solved in free jqGrid, but if you do prefer to use commercial version of Guriddo jqGrid JS的选项,那我推荐您可以按以下方式重写您的代码:

var myErrorFunc = function (data) {
        return 'Error: ' + data.responseText;
    },
    addEditFormOptions = {
        editCaption: "Edit Item",
        recreateForm: true,
        checkOnUpdate : true,
        checkOnSubmit : true,
        closeAfterEdit: true,
        closeAfterAdd: true,
        editData: {
            mediaPlanId : function() { return mpId; }
        },
        errorTextFormat: myErrorFunc
    },
    delOptions = {
        errorTextFormat: myErrorFunc
    };

$('#jqGrid').navGrid('#jqGridPager', { search: false, refresh: false },
    addEditFormOptions, addEditFormOptions, delOptions);

我认为更好的方法是先阅读 documentation of Guriddo jqGrid,它将指导您将参数放在哪里。